summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-04-30 12:56:11 +0200
committerDaniel Friesel <derf@finalrewind.org>2019-04-30 12:56:11 +0200
commita57a24c2d68daa4d4561ed9035c863e574cdc70a (patch)
treeb0cacb635d65e9f220748142080b832a43de7342
parent99aa3a4a0d467fd83ba78096cf34113df797f0d8 (diff)
add "active user count" munin command
-rw-r--r--lib/Travelynx/Command/munin.pm12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/Travelynx/Command/munin.pm b/lib/Travelynx/Command/munin.pm
index a7ee9b1..110e058 100644
--- a/lib/Travelynx/Command/munin.pm
+++ b/lib/Travelynx/Command/munin.pm
@@ -21,6 +21,7 @@ sub run {
my $db = $self->app->pg->db;
my $now = DateTime->now( time_zone => 'Europe/Berlin' );
+ my $active = $now->clone->subtract( months => 1 );
my $checkin_window_query
= qq{select count(*) as count from journeys where checkin_time > to_timestamp(?);};
@@ -29,6 +30,17 @@ sub run {
$db->select( 'users', 'count(*) as count', { status => 1 } )
->hash->{count} );
query_to_munin(
+ 'active_user_count',
+ $db->select(
+ 'users',
+ 'count(*) as count',
+ {
+ status => 1,
+ last_seen => { '>', $active }
+ }
+ )->hash->{count}
+ );
+ query_to_munin(
'checkins_24h',
$db->query( $checkin_window_query,
$now->subtract( hours => 24 )->epoch )->hash->{count}