diff options
author | Dylan William Hardison <dylan@hardison.net> | 2017-06-09 18:02:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-09 18:02:51 +0200 |
commit | b1abfe7caca072a36c312d6961ff9fbbfe306933 (patch) | |
tree | 056ff591596080de78f0f67448f9b6cfdd9c8560 /extensions | |
parent | 03bc182966d1fdd852be40d901ce998b1eaec7b7 (diff) | |
download | bugzilla-b1abfe7caca072a36c312d6961ff9fbbfe306933.tar.gz bugzilla-b1abfe7caca072a36c312d6961ff9fbbfe306933.tar.xz |
Bug 1067812 - Add date selectors to the review history API
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/Review/lib/WebService.pm | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/extensions/Review/lib/WebService.pm b/extensions/Review/lib/WebService.pm index ea8910d50..c17e4c12d 100644 --- a/extensions/Review/lib/WebService.pm +++ b/extensions/Review/lib/WebService.pm @@ -130,16 +130,34 @@ sub flag_activity { my $limit = delete $params->{limit}; my $offset = delete $params->{offset}; + my $after = delete $params->{after}; + my $before = delete $params->{before}; my $max_results = Bugzilla->params->{max_search_results}; if (!$limit || $limit > $max_results) { $limit = $max_results; } + if ($after && $after =~ /^(\d{4}-\d{1,2}-\d{1,2})$/) { + $after = $1; + } + else { + my $now = DateTime->now; + $now->subtract(days => 30); + $after = $now->ymd('-'); + } + + if ($before && $before =~ /^(\d{4}-\d{1,2}-\d{1,2})$/) { + $before = $1; + } + else { + my $now = DateTime->now; + $before = $now->ymd('-'); + } + $match_criteria{LIMIT} = $limit; $match_criteria{OFFSET} = $offset if defined $offset; - # Hide data until Bug 1073364 is resolved. - $match_criteria{WHERE} = { 'flag_when > ?' => '2014-09-23 21:17:16' }; + $match_criteria{WHERE} = { 'date(flag_when) BETWEEN ? AND ?' => [$after, $before] }; # Throw error if no other parameters have been passed other than limit and offset if (!grep(!/^(LIMIT|OFFSET)$/, keys %match_criteria)) { |