<commit_before>package Maximus::Task::SCM::AutoDiscover;
use Moose;
use DateTime;
use JSON::Any;
use namespace::autoclean;

with 'Maximus::Role::Task';
with 'Maximus::Role::Task::SCM';

=head1 NAME

Maximus::Task::SCM::AutoDiscover - Auto Discover modules from a SCM

=head1 SYNOPSIS

	use Maximus::Task::SCM::AutoDiscover;
	$task->run($scm_id); # SCM ID number
	$task->run($scm); # Maximus::Schema::Result::Scm

=head1 DESCRIPTION

Update module database.

=head1 METHODS

=head2 run

Run task
=cut

sub run {
    my ($self, $scm) = @_;
    unless (ref($scm) eq 'Maximus::Schema::Result::Scm') {
        $scm = $self->schema->resultset('Scm')->find({id => $scm});
    }

    my $source = $self->get_source($scm);
    $self->response([$source->auto_discover]);

    $scm->update(
        {   auto_discover_request  => DateTime->now(),
            auto_discover_response => JSON::Any->objToJson($self->response),
        }
    );

    1;
}
<commit_msg>No need for manual conversion to JSON<commit_after>package Maximus::Task::SCM::AutoDiscover;
use Moose;
use DateTime;
use namespace::autoclean;

with 'Maximus::Role::Task';
with 'Maximus::Role::Task::SCM';

=head1 NAME

Maximus::Task::SCM::AutoDiscover - Auto Discover modules from a SCM

=head1 SYNOPSIS

	use Maximus::Task::SCM::AutoDiscover;
	$task->run($scm_id); # SCM ID number
	$task->run($scm); # Maximus::Schema::Result::Scm

=head1 DESCRIPTION

Update module database.

=head1 METHODS

=head2 run

Run task
=cut

sub run {
    my ($self, $scm) = @_;
    unless (ref($scm) eq 'Maximus::Schema::Result::Scm') {
        $scm = $self->schema->resultset('Scm')->find({id => $scm});
    }

    my $source = $self->get_source($scm);
    $self->response([$source->auto_discover]);

    $scm->update(
        {   auto_discover_request  => DateTime->now(),
            auto_discover_response => $self->response,
        }
    );

    1;
}

{'fraction_non_alphanumeric': 0.17628374801482266, 'fraction_numerical': 0.006352567496029645, 'mean_word_length': 4.026595744680851, 'pattern_counts': {'":': 0, '<': 3, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6191815', 'n_tokens_mistral': 720, 'n_tokens_neox': 685, 'n_words': 138}