From 1f3b3c742ce91a722d713fada8f5d5829ed0ae7a Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 5 Apr 2021 09:38:08 +0200 Subject: 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) --- lib/Travelynx/Command/munin.pm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'lib/Travelynx/Command') 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} ); -- cgit v1.2.3