From c0fcc7f5d5020d8f2802b853e4b77e9e973180c5 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sat, 28 Apr 2018 22:10:11 +0100 Subject: [PATCH] #405 Inventory reports default to all time to fix missing IPs --- Changes | 6 ++++++ lib/App/Netdisco/Util/Web.pm | 8 +++++++- share/views/sidebar/report/ipinventory.tt | 2 +- share/views/sidebar/report/subnets.tt | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Changes b/Changes index 6e36725f..45940c06 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,9 @@ +2.039027 - 2018-04-28 + + [BUG FIXES] + + * #405 Inventory reports default to all time to fix missing IPs + 2.039026 - 2018-04-28 [ENHANCEMENTS] diff --git a/lib/App/Netdisco/Util/Web.pm b/lib/App/Netdisco/Util/Web.pm index 9cbf8669..f4d9d70a 100644 --- a/lib/App/Netdisco/Util/Web.pm +++ b/lib/App/Netdisco/Util/Web.pm @@ -193,12 +193,18 @@ Takes an interval in days, weeks, months, or years in a format like '7 days' and returns a date range in the format 'YYYY-MM-DD to YYYY-MM-DD' by subtracting the interval from the current date. +If C<$interval> is not passed, epoch zero (1970-01-01) is used as the start. + =cut sub interval_to_daterange { my $interval = shift; - return unless $interval =~ m/^(?:\d+)\s+(?:day|week|month|year)s?$/; + unless ($interval + and $interval =~ m/^(?:\d+)\s+(?:day|week|month|year)s?$/) { + + return "1970-01-01 to " . Time::Piece->new->ymd; + } my %const = ( day => ONE_DAY, diff --git a/share/views/sidebar/report/ipinventory.tt b/share/views/sidebar/report/ipinventory.tt index d62f70b3..c5c01e25 100644 --- a/share/views/sidebar/report/ipinventory.tt +++ b/share/views/sidebar/report/ipinventory.tt @@ -22,7 +22,7 @@
+ (params.exists('daterange') ? params.daterange : to_daterange()) | html_entity %]"/>
diff --git a/share/views/sidebar/report/subnets.tt b/share/views/sidebar/report/subnets.tt index 27db0844..55314be6 100644 --- a/share/views/sidebar/report/subnets.tt +++ b/share/views/sidebar/report/subnets.tt @@ -24,7 +24,7 @@
+ (params.exists('daterange') ? params.daterange : to_daterange()) | html_entity %]"/>