diff options
author | Daniel Friesel <derf@finalrewind.org> | 2021-04-05 09:38:08 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2021-04-05 09:46:28 +0200 |
commit | 1f3b3c742ce91a722d713fada8f5d5829ed0ae7a (patch) | |
tree | 1ffcb2c3515b6b536d461d773179be7809a56d69 /lib/Travelynx | |
parent | 11727e0f99decf316ae19e6ccf0321610ab7a6f5 (diff) |
munin: fix date range calculation
TODO: handle CET -> CEST transition (there's a day each year where 2am does not
exist and DateTime does not like it)
Diffstat (limited to 'lib/Travelynx')
-rw-r--r-- | lib/Travelynx/Command/munin.pm | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/Travelynx/Command/munin.pm b/lib/Travelynx/Command/munin.pm index 5e67f5a..28dae18 100644 --- a/lib/Travelynx/Command/munin.pm +++ b/lib/Travelynx/Command/munin.pm @@ -1,4 +1,5 @@ package Travelynx::Command::munin; + # Copyright (C) 2020 Daniel Friesel # # SPDX-License-Identifier: AGPL-3.0-or-later @@ -48,16 +49,17 @@ sub run { query_to_munin( 'checkins_24h', $db->query( $checkin_window_query, - $now->subtract( hours => 24 )->epoch )->hash->{count} + $now->clone->subtract( hours => 24 )->epoch )->hash->{count} + ); + query_to_munin( + 'checkins_7d', + $db->query( $checkin_window_query, + $now->clone->subtract( days => 7 )->epoch )->hash->{count} ); - query_to_munin( 'checkins_7d', - $db->query( $checkin_window_query, $now->subtract( days => 7 )->epoch ) - ->hash->{count} ); query_to_munin( 'checkins_30d', - $db->query( - $checkin_window_query, $now->subtract( days => 30 )->epoch - )->hash->{count} + $db->query( $checkin_window_query, + $now->clone->subtract( days => 30 )->epoch )->hash->{count} ); query_to_munin( 'polylines', $db->select( 'polylines', 'count(*) as count' )->hash->{count} ); |