<commit_before><?php

namespace App\Nova\Metrics;

use App\Attendance;
use Illuminate\Http\Request;
use Laravel\Nova\Metrics\Trend;

class AttendancePerWeek extends Trend
{
    /**
     * Calculate the value of the metric.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return mixed
     */
    public function calculate(Request $request)
    {
        // This is slightly hacky, but it works. Otherwise, responses with a created date of midnight (as created by
        // some forms) were pushed back to the previous day in the metric. This acts like we're in GMT while
        // calculating the attendance.
        $originalTimezone = $request->timezone;
        $request->timezone = 'Etc/GMT';

        // If we're on a team page, not the main dashboard, filter to that team
        if ($request->resourceId) {
            $query = (new Attendance())
                ->newQuery()
                ->where('attendable_id', $request->resourceId)
                ->where('attendable_type', 'App\Team');

            $result = $this->countByWeeks($request, $query)->showLatestValue();
        } else {
            $result = $this->countByWeeks($request, Attendance::class)->showLatestValue();
        }

        $request->timezone = $originalTimezone;

        return $result;
    }

    /**
     * Get the ranges available for the metric.
     *
     * @return array
     */
    public function ranges()
    {
        return [
            4 => '1 Month',
            8 => '2 Months',
            12 => '3 Months',
            26 => '6 Months',
            52 => '1 Year',
        ];
    }

    /**
     * Determine for how many minutes the metric should be cached.
     *
     * @return  \DateTimeInterface|\DateInterval|float|int
     */
    public function cacheFor()
    {
        // return now()->addMinutes(5);
    }

    /**
     * Get the URI key for the metric.
     *
     * @return string
     */
    public function uriKey()
    {
        return 'attendance-per-week';
    }
}
<commit_msg>Remove 1 month option from Attendance Per Week metric<commit_after><?php

namespace App\Nova\Metrics;

use App\Attendance;
use Illuminate\Http\Request;
use Laravel\Nova\Metrics\Trend;

class AttendancePerWeek extends Trend
{
    /**
     * Calculate the value of the metric.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return mixed
     */
    public function calculate(Request $request)
    {
        // This is slightly hacky, but it works. Otherwise, responses with a created date of midnight (as created by
        // some forms) were pushed back to the previous day in the metric. This acts like we're in GMT while
        // calculating the attendance.
        $originalTimezone = $request->timezone;
        $request->timezone = 'Etc/GMT';

        // If we're on a team page, not the main dashboard, filter to that team
        if ($request->resourceId) {
            $query = (new Attendance())
                ->newQuery()
                ->where('attendable_id', $request->resourceId)
                ->where('attendable_type', 'App\Team');

            $result = $this->countByWeeks($request, $query)->showLatestValue();
        } else {
            $result = $this->countByWeeks($request, Attendance::class)->showLatestValue();
        }

        $request->timezone = $originalTimezone;

        return $result;
    }

    /**
     * Get the ranges available for the metric.
     *
     * @return array
     */
    public function ranges()
    {
        return [
            8 => '2 Months',
            12 => '3 Months',
            26 => '6 Months',
            52 => '1 Year',
        ];
    }

    /**
     * Determine for how many minutes the metric should be cached.
     *
     * @return  \DateTimeInterface|\DateInterval|float|int
     */
    public function cacheFor()
    {
        // return now()->addMinutes(5);
    }

    /**
     * Get the URI key for the metric.
     *
     * @return string
     */
    public function uriKey()
    {
        return 'attendance-per-week';
    }
}

{'fraction_non_alphanumeric': 0.11783596837944664, 'fraction_numerical': 0.0066699604743083, 'mean_word_length': 1.9066762383345297, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 38, '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': '3208923', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1144, 'n_words': 337}