<commit_before><?php

declare(strict_types=1);

// phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter,SlevomatCodingStandard.Functions.UnusedParameter

namespace App\Nova\Actions;

use Illuminate\Bus\Queueable;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Actions\Action;
use Laravel\Nova\Fields\DateTime;
use Illuminate\Support\Collection;
use Laravel\Nova\Fields\ActionFields;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use App\Jobs\GenerateResumeBook as GenerateJob;

class GenerateResumeBook extends Action
{
    use InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Perform the action on the given models.
     *
     * @param \Laravel\Nova\Fields\ActionFields  $fields
     * @param \Illuminate\Support\Collection  $models
     *
     * @return array<string,string>
     */
    public function handle(ActionFields $fields, Collection $models): array
    {
        $job = new GenerateJob($fields->major, $fields->resume_date_cutoff);
        $job->handle();

        return Action::download(
            route('api.v1.resumebook.show', ['tag' => $job->datecode.($fields->major ? '-'.$fields->major : '')]),
            basename($job->path)
        );
    }

    /**
     * Get the fields available on the action.
     *
     * @return array<\Laravel\Nova\Fields\Field>
     */
    public function fields(): array
    {
        return [
            Text::make('Major')
                ->nullable()
                ->help('Only combine resumes for this major abbreviation (e.g., ME, EE, CMPE, CS).'),

            DateTime::make('Resume Date Cutoff')
                ->required(true)
                ->help('Only export resumes uploaded after this date.'),
        ];
    }

    /**
     * Indicates if this action is only available on the resource detail view.
     *
     * @var bool
     */
    public $onlyOnDetail = true;
}<commit_msg>Add error handling to nova action<commit_after><?php

declare(strict_types=1);

// phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter,SlevomatCodingStandard.Functions.UnusedParameter

namespace App\Nova\Actions;

use Illuminate\Bus\Queueable;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Actions\Action;
use Laravel\Nova\Fields\DateTime;
use Illuminate\Support\Collection;
use Laravel\Nova\Fields\ActionFields;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use App\Jobs\GenerateResumeBook as GenerateJob;

class GenerateResumeBook extends Action
{
    use InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Perform the action on the given models.
     *
     * @param \Laravel\Nova\Fields\ActionFields  $fields
     * @param \Illuminate\Support\Collection  $models
     *
     * @return array<string,string>
     */
    public function handle(ActionFields $fields, Collection $models): array
    {
        $job = new GenerateJob($fields->major, $fields->resume_date_cutoff);
        $job->handle();

        if (null === $job->path) {
            return Action::danger('An unknown error occurred.');
        }

        return Action::download(
            route('api.v1.resumebook.show', ['tag' => $job->datecode.($fields->major ? '-'.$fields->major : '')]),
            basename($job->path)
        );
    }

    /**
     * Get the fields available on the action.
     *
     * @return array<\Laravel\Nova\Fields\Field>
     */
    public function fields(): array
    {
        return [
            Text::make('Major')
                ->nullable()
                ->help('Only combine resumes for this major abbreviation (e.g., ME, EE, CMPE, CS).'),

            DateTime::make('Resume Date Cutoff')
                ->required(true)
                ->help('Only export resumes uploaded after this date.'),
        ];
    }

    /**
     * Indicates if this action is only available on the resource detail view.
     *
     * @var bool
     */
    public $onlyOnDetail = true;
}
{'fraction_non_alphanumeric': 0.1238264399898503, 'fraction_numerical': 0.0010149708195889369, 'mean_word_length': 2.6298342541436464, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6424687', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1147, 'n_words': 261}