<commit_before>package NP::Model::ZoneServerCount;
use strict;


package NP::Model::ZoneServerCount::Manager;
use strict;

sub first_stats {
    my ($class, $zone, $year) = @_;
    my $dbh = NP::Model->dbh;
    my $id;
    if ($year) {
        ($id) = $dbh->selectrow_array(q[select id from zone_server_counts where zone_id=? and year(date)=? order by date limit 1],
                                      undef,
                                      $zone->id, $year,
                                     );
    }
    else {
        ($id) = $dbh->selectrow_array(q[select id from zone_server_counts where zone_id=? order by date limit 1],
                                      undef,
                                      $zone->id,
                                     );
    }
    return unless $id;
    $class->fetch(id => $id);
} 

sub ago {
    my $self = shift;
    Time::Duration::ago(DateTime->now->epoch - $self->date->epoch, 2);
}



1;
<commit_msg>make the historical zone counts work<commit_after>package NP::Model::ZoneServerCount;
use strict;
use Time::Duration;

sub ago {
    my $self = shift;
    Time::Duration::ago(DateTime->today->epoch - $self->date->epoch, 2);
}

package NP::Model::ZoneServerCount::Manager;
use strict;

sub first_stats {
    my ($class, $zone, $year) = @_;
    my $dbh = NP::Model->dbh;
    my $id;
    if ($year) {
        ($id) = $dbh->selectrow_array(q[select id from zone_server_counts where zone_id=? and year(date)=? order by date limit 1],
                                      undef,
                                      $zone->id, $year,
                                     );
    }
    else {
        ($id) = $dbh->selectrow_array(q[select id from zone_server_counts where zone_id=? order by date limit 1],
                                      undef,
                                      $zone->id,
                                     );
    }
    return unless $id;
    $class->fetch(id => $id);
} 


1;

{'fraction_non_alphanumeric': 0.13003569607343193, 'fraction_numerical': 0.00407955124936257, 'mean_word_length': 1.4961832061068703, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5693629', 'n_tokens_mistral': 607, 'n_tokens_neox': 575, 'n_words': 141}