<commit_before>package MediaWords::Job::TM::SnapshotTopic;

#
# Snapshot various topic queries to csv and build a gexf file
#

use strict;
use warnings;

use Moose;
with 'MediaWords::JobManager::AbstractStatefulJob';

use Modern::Perl "2015";
use MediaWords::CommonLibs;

use MediaWords::DB;
use MediaWords::TM::Snapshot;

# only run one job for each topic at a time
sub get_run_lock_arg
{
    return 'topics_id';
}

sub get_state_table_info
{
    return { table => 'snapshots', state => 'state', message => 'message' };
}

# Run job
sub run($;$)
{
    my ( $self, $args ) = @_;

    my $db = MediaWords::DB::connect_to_db();

    my $topics_id  = $args->{ topics_id };
    my $note       = $args->{ note };
    my $bot_policy = $args->{ bot_policy };
    my $periods    = $args->{ periods };
    my $snapshots_id = $args->{ snapshots_id };
<commit_msg>Explicitly implement get_run_lock_type() in topics-snapshot worker<commit_after>package MediaWords::Job::TM::SnapshotTopic;

#
# Snapshot various topic queries to csv and build a gexf file
#

use strict;
use warnings;

use Moose;
with 'MediaWords::JobManager::AbstractStatefulJob';

use Modern::Perl "2015";
use MediaWords::CommonLibs;

use MediaWords::DB;
use MediaWords::TM::Snapshot;

# only run one job for each topic at a time
sub get_run_lock_arg
{
    return 'topics_id';
}

sub get_run_lock_type
{
    return 'MediaWords::Job::TM::SnapshotTopic';
}

sub get_state_table_info
{
    return { table => 'snapshots', state => 'state', message => 'message' };
}

# Run job
sub run($;$)
{
    my ( $self, $args ) = @_;

    my $db = MediaWords::DB::connect_to_db();

    my $topics_id  = $args->{ topics_id };
    my $note       = $args->{ note };
    my $bot_policy = $args->{ bot_policy };
    my $periods    = $args->{ periods };
    my $snapshots_id = $args->{ snapshots_id };

{'fraction_non_alphanumeric': 0.14713896457765668, 'fraction_numerical': 0.004359673024523161, 'mean_word_length': 4.016393442622951, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '6079899', 'n_tokens_mistral': 666, 'n_tokens_neox': 641, 'n_words': 175}