summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorFrank Becker <Frank@Frank-Becker.de>2012-04-13 07:05:17 +0200
committerDave Lawrence <dlawrence@mozilla.com>2012-04-13 07:05:17 +0200
commita699a59ef4fd7bab94d6256a586b203dcff924c3 (patch)
treeba354198b0af1d9dc98cb7f6f5a27445bc6ad259 /Bugzilla
parent1ea1d48d86403d1d7a5113f5c303988c8f4ed74d (diff)
downloadbugzilla-a699a59ef4fd7bab94d6256a586b203dcff924c3.tar.gz
bugzilla-a699a59ef4fd7bab94d6256a586b203dcff924c3.tar.xz
Bug 740536 - Webservice for maximum time of audit_log
r=dkl, a=LpSolit
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/WebService/Bugzilla.pm71
1 files changed, 70 insertions, 1 deletions
diff --git a/Bugzilla/WebService/Bugzilla.pm b/Bugzilla/WebService/Bugzilla.pm
index 82f6f8630..f441cee90 100644
--- a/Bugzilla/WebService/Bugzilla.pm
+++ b/Bugzilla/WebService/Bugzilla.pm
@@ -11,7 +11,8 @@ use strict;
use base qw(Bugzilla::WebService);
use Bugzilla::Constants;
use Bugzilla::Util qw(datetime_from);
-use Bugzilla::WebService::Util qw(filter_wants);
+use Bugzilla::WebService::Util qw(validate filter_wants);
+use Bugzilla::Util qw(trick_taint);
use DateTime;
@@ -114,6 +115,33 @@ sub time {
};
}
+sub last_audit_time {
+ my ($self, $params) = validate(@_, 'class');
+ my $dbh = Bugzilla->dbh;
+
+ my $sql_statement = "SELECT MAX(at_time) FROM audit_log";
+ my $class_values = $params->{class};
+ my @class_values_quoted;
+ foreach my $class_value (@$class_values) {
+ push (@class_values_quoted, $dbh->quote($class_value))
+ if $class_value =~ /^Bugzilla(::[a-zA-Z0-9_]+)*$/;
+ }
+
+ if (@class_values_quoted) {
+ $sql_statement .= " WHERE " . $dbh->sql_in('class', \@class_values_quoted);
+ }
+
+ my $last_audit_time = $dbh->selectrow_array("$sql_statement");
+
+ # All Webservices return times in UTC; Use UTC here for backwards compat.
+ # Hardcode values where appropriate
+ $last_audit_time = datetime_from($last_audit_time, 'UTC');
+
+ return {
+ last_audit_time => $self->type('dateTime', $last_audit_time)
+ };
+}
+
sub parameters {
my ($self, $args) = @_;
my $user = Bugzilla->login();
@@ -390,3 +418,44 @@ never be stable.
=back
=back
+
+=head2 last_audit_time
+
+B<EXPERIMENTAL>
+
+=over
+
+=item B<Description>
+
+Gets the latest time of the audit_log table.
+
+=item B<Params>
+
+You can pass the optional parameter C<class> to get the maximum for only
+the listed classes.
+
+=over
+
+=item C<class> (array) - An array of strings representing the class names.
+
+B<Note:> The class names are defined as "Bugzilla::<class_name>". For the product
+use Bugzilla:Product.
+
+=back
+
+=item B<Returns>
+
+A hash with a single item, C<last_audit_time>, that is the maximum of the
+at_time from the audit_log.
+
+=item B<Errors> (none)
+
+=item B<History>
+
+=over
+
+=item Added in Bugzilla B<4.4>.
+
+=back
+
+=back