Created
November 16, 2016 19:19
-
-
Save dklawren/f93b0ed761615fe86bafe1f1e8d506a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use utf8; | |
use lib qw(. local/lib/perl5); | |
use Bugzilla; | |
use Bugzilla::FlagType; | |
use Bugzilla::User; | |
my $dbh = Bugzilla->dbh; | |
my $prev_set_sth = $dbh->prepare("SELECT 1 FROM flag_state_activity | |
WHERE id < ? AND flag_id = ? AND status IN ('+', '-') | |
ORDER BY id DESC LIMIT 1"); | |
my $all_sth = $dbh->prepare("SELECT id, flag_when, type_id, setter_id, flag_id, status | |
FROM flag_state_activity | |
WHERE YEAR(flag_when) = 2016 AND MONTH(flag_when) > 2 AND type_id != 800", | |
{ Slice => {} }); | |
$all_sth->execute(); | |
while (my $row = $all_sth->fetchrow_hashref()) { | |
my $id = $row->{id}; | |
my $when = $row->{flag_when}; | |
my $type = Bugzilla::FlagType->new({ id => $row->{type_id}, cache => 1 }); | |
my $setter = Bugzilla::User->new({ id => $row->{setter_id}, cache => 1 }); | |
my $flag_id = $row->{flag_id}; | |
my $status = $row->{status}; | |
# Was the setter able to set the flag | |
if ((($status eq '+' || $status eq '-') && !$setter->can_set_flag($type)) | |
|| ($status eq '?' && !$setter->can_request_flag($type))) | |
{ | |
print STDERR $setter->login . " inappropriately set " . $type->name . $status . " on " . $when . "\n"; | |
} | |
# Was the setter able to clear the set flag | |
if ($status eq 'X') { | |
$prev_set_sth->execute($id, $flag_id); | |
my $prev_set = $prev_set_sth->fetchrow_array(); | |
if ($prev_set && !$setter->can_set_flag($type)) { | |
print STDERR $setter->login . " inappropriately cleared " . $type->name . " on " . $when . "\n"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment