diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2025-10-19 16:51:42 +0200 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2025-10-19 16:51:42 +0200 |
commit | 0241cf550ad25675db1f0c8d7a0000a325a86cbf (patch) | |
tree | 6d5630a2da7f478a20189cae11b65e9db195ebb3 /lib/Travelynx/Command/stats.pm | |
parent | 40417bc2821db3e824b6ac00eaa1a01ed83a9ea4 (diff) |
stats: perltidy, more frequent updates
Diffstat (limited to 'lib/Travelynx/Command/stats.pm')
-rw-r--r-- | lib/Travelynx/Command/stats.pm | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/Travelynx/Command/stats.pm b/lib/Travelynx/Command/stats.pm index c6522da..1ba1db9 100644 --- a/lib/Travelynx/Command/stats.pm +++ b/lib/Travelynx/Command/stats.pm @@ -14,16 +14,17 @@ has usage => sub { shift->extract_usage }; sub refresh_all { my ($self) = @_; - my $db = $self->app->pg->db; + my $db = $self->app->pg->db; my $now = DateTime->now( time_zone => 'Europe/Berlin' ); say 'Refreshing all stats, this may take a while ...'; - my $total = $db->select( 'users', 'count(*) as count', { status => 1 } )->hash->{count}; + my $total = $db->select( 'users', 'count(*) as count', { status => 1 } ) + ->hash->{count}; my $i = 1; for - my $user ( $db->select( 'users', ['id'], { status => 1 } )->hashes->each ) + my $user ( $db->select( 'users', ['id'], { status => 1 } )->hashes->each ) { my $tx = $db->begin; $self->app->journeys->generate_missing_stats( uid => $user->{id} ); @@ -32,8 +33,8 @@ sub refresh_all { year => $now->year ); $tx->commit; - if ($i == $total or ($i % 100) == 0) { - printf("%.f%% complete", $i * 100 / $total); + if ( $i == $total or ( $i % 10 ) == 0 ) { + printf( "%.f%% complete", $i * 100 / $total ); } } } @@ -41,7 +42,7 @@ sub refresh_all { sub run { my ( $self, $cmd, @arg ) = @_; - if ($cmd eq 'refresh-all') { + if ( $cmd eq 'refresh-all' ) { $self->refresh_all(@arg); } |