]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 324535 - Allow the use of relative dates in charts
authorKohei Yoshino <kohei.yoshino@gmail.com>
Tue, 20 Nov 2018 22:46:54 +0000 (17:46 -0500)
committerGitHub <noreply@github.com>
Tue, 20 Nov 2018 22:46:54 +0000 (17:46 -0500)
Bugzilla/Chart.pm
Bugzilla/Util/DateTime.pm [moved from extensions/BMO/lib/Util.pm with 83% similarity]
extensions/BMO/lib/Reports/ReleaseTracking.pm
extensions/BMO/lib/Reports/UserActivity.pm

index 9dce19eb9d42939da25c2ea81c52a5c32442c27d..6c9823c585c684ac312c73f5492efdb75dca29fc 100644 (file)
@@ -19,6 +19,7 @@ use warnings;
 
 use Bugzilla::Error;
 use Bugzilla::Util;
+use Bugzilla::Util::DateTime;
 use Bugzilla::Series;
 
 use Date::Format;
@@ -87,7 +88,7 @@ sub init {
     # Make sure the dates are ones we are able to interpret
     foreach my $date ('datefrom', 'dateto') {
         if ($self->{$date}) {
-            $self->{$date} = str2time($self->{$date})
+            $self->{$date} = parse_date($self->{$date})
               || ThrowUserError("illegal_date", { date => $self->{$date}});
         }
     }
similarity index 83%
rename from extensions/BMO/lib/Util.pm
rename to Bugzilla/Util/DateTime.pm
index dc9c904f98851150c98c944383d06164e0e8e6d0..cb23c8058d80fc610e99ed2203f1a8ebf57abbfe 100644 (file)
@@ -5,7 +5,7 @@
 # This Source Code Form is "Incompatible With Secondary Licenses", as
 # defined by the Mozilla Public License, v. 2.0.
 
-package Bugzilla::Extension::BMO::Util;
+package Bugzilla::Util::DateTime;
 
 use 5.10.1;
 use strict;
@@ -20,8 +20,7 @@ use base qw(Exporter);
 
 our @EXPORT = qw( string_to_datetime
                   time_to_datetime
-                  parse_date
-                  is_active_status_field );
+                  parse_date );
 
 sub string_to_datetime {
     my $input = shift;
@@ -75,18 +74,4 @@ sub parse_date {
     return str2time($str);
 }
 
-sub is_active_status_field {
-    my ($field) = @_;
-
-    if ($field->type == FIELD_TYPE_EXTENSION
-        && $field->isa('Bugzilla::Extension::TrackingFlags::Flag')
-        && $field->flag_type eq 'tracking'
-        && $field->name =~ /_status_/
-    ) {
-        return $field->is_active;
-    }
-
-    return 0;
-}
-
 1;
index 9fba1e14b07ae7fbff19b90bce6eb2ed9c09e1dd..1a4c1071991293c70cfb702b7d6c74e28da8c8b0 100644 (file)
@@ -13,7 +13,6 @@ use warnings;
 
 use Bugzilla::Constants;
 use Bugzilla::Error;
-use Bugzilla::Extension::BMO::Util;
 use Bugzilla::Field;
 use Bugzilla::FlagType;
 use Bugzilla::Util qw(trick_taint validate_date);
@@ -288,7 +287,7 @@ sub report {
     foreach my $product (@usable_products) {
         my @fields =
             sort { $a->sortkey <=> $b->sortkey }
-            grep { is_active_status_field($_) }
+            grep { _is_active_status_field($_) }
             Bugzilla->active_custom_fields({ product => $product });
         my @field_ids = map { $_->id } @fields;
         if (!scalar @fields) {
@@ -513,4 +512,18 @@ sub _parse_query {
     return $query;
 }
 
+sub _is_active_status_field {
+    my ($field) = @_;
+
+    if ($field->type == FIELD_TYPE_EXTENSION
+        && $field->isa('Bugzilla::Extension::TrackingFlags::Flag')
+        && $field->flag_type eq 'tracking'
+        && $field->name =~ /_status_/
+    ) {
+        return $field->is_active;
+    }
+
+    return 0;
+}
+
 1;
index 8dfe0c5cd639ca400b50246a724c81ba33cac94f..4a4de8bb8495987f8677901dbeaf61a1e5d66fd4 100644 (file)
@@ -12,9 +12,9 @@ use strict;
 use warnings;
 
 use Bugzilla::Error;
-use Bugzilla::Extension::BMO::Util;
 use Bugzilla::User;
 use Bugzilla::Util qw(trim);
+use Bugzilla::Util::DateTime;
 use DateTime;
 
 sub report {