<commit_before><?php namespace App\Http\Controllers\Acp;

use App\Action\Acp\ApplyIndexGoodsAction;
use App\Metric;
use App\Scope\MetricWeekScope;
use Carbon\Carbon;

class Metrics
{
    public function index(ApplyIndexGoodsAction $applyIndexGoods)
    {
        $applyIndexGoods->execute(new Metric);

        $events = Metric::possibleMetrics();
        $metrics = $dates = [];

        Metric::tap(new MetricWeekScope)
            ->get()
            ->map(function (Metric $item) use (&$metrics, &$dates) {
                $dates[$item->date->toDateString()] = true;
                $metrics[$item->event][$item->date->toDateString()] = $item->count;
            });

        return view('acp.metrics.index', [
            'dates' => $dates,
            'events' => $events,
            'metrics' => $metrics,
        ]);
    }

    public function show(string $event)
    {
        \Breadcrumbs::push($event);

        $metrics = Metric::where('event', $event)->get();
        $lastDay = sizeof($metrics) ? Carbon::parse($metrics->last()->date) : now();
        $firstDay = sizeof($metrics) ? Carbon::parse($metrics->first()->date) : now();

        return view('acp.metrics.show', [
            'event' => $event,
            'lastDay' => $lastDay,
            'metrics' => $metrics->pluck('count', 'date'),
            'firstDay' => $firstDay,<commit_msg>Поправлен вывод метрик<commit_after><?php namespace App\Http\Controllers\Acp;

use App\Action\Acp\ApplyIndexGoodsAction;
use App\Metric;
use App\Scope\MetricWeekScope;
use Carbon\Carbon;

class Metrics
{
    public function index(ApplyIndexGoodsAction $applyIndexGoods)
    {
        $applyIndexGoods->execute(new Metric);

        $events = Metric::possibleMetrics();
        $metrics = $dates = [];

        Metric::tap(new MetricWeekScope)
            ->get()
            ->map(function (Metric $item) use (&$metrics, &$dates) {
                $dates[$item->date->toDateString()] = true;
                $metrics[$item->event][$item->date->toDateString()] = $item->count;
            });

        return view('acp.metrics.index', [
            'dates' => $dates,
            'events' => $events,
            'metrics' => $metrics,
        ]);
    }

    public function show(string $event)
    {
        \Breadcrumbs::push($event);

        $metrics = Metric::where('event', $event)->pluck('count', 'date');
        $lastDay = Carbon::parse(array_key_last($metrics->toArray()));
        $firstDay = Carbon::parse(array_key_first($metrics->toArray()));

        return view('acp.metrics.show', [
            'event' => $event,
            'lastDay' => $lastDay,
            'metrics' => $metrics,
            'firstDay' => $firstDay,
{'fraction_non_alphanumeric': 0.17049666419570053, 'fraction_numerical': 0.0, 'mean_word_length': 2.4338422391857506, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 44, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6184044', 'n_tokens_mistral': 822, 'n_tokens_neox': 810, 'n_words': 139}