BZ-Client
view release on metacpan or search on metacpan
eg/nagios2bugzilla/talktobugzilla.pl view on Meta::CPAN
$log->logdie(sprintf 'Something bad happened searching for %s via alias %s, error: %s',
$alias , $params{LASTSERVICEPROBLEMID} , Dumper( $_ ) );
};
unless ( ref $search eq 'ARRAY' and @$search ) {
$log->info( "Unable to locate $params{LASTSERVICEPROBLEMID}, NO-OP");
try { if ($delete) { $log->debug('Removing file: ' .$f->basename); $f->remove() }}
catch { $log->warn(sprintf 'Failed to delete %s because: %s', $f->basename, $_) };
next;
}
my $bug = $search->[0];
$log->info( 'Found ', $bug->alias(), ' with ', $bug->id() );
## got this far? lets close the bug then
close_bug( $f, $bug, \%params );
}
$log->info( 'Finished handling recoveries' );
}
}
{
sub stir_stalled {
$log->info('Going to stir stalled bugs');
my %search = (
status => [ 'NEW', 'ASSIGNED', 'REOPENED' ],
keywords => $team{keywords}
);
my @bugs = try {
return BZ::Client::Bug->search( $client, \%search )
}
catch {
$log->logdie(sprintf 'Something bad happened searching for NEW, ASSIGNED AND REOPENED bugs: %s',
Dumper( $_ ) );
};
if (@bugs) {
my $now = DateTime->now();
for my $bug (@bugs) {
# create time = last change, nothing has happened
if (0 == DateTime->compare($bug->last_change_time,$bug->creation_time)) {
if ($now->delta_ms($bug->last_change_time)->in_units('hours') < $acktime ) {
# give people time to look at it
$log->debug(sprintf 'Bug %d is NEW but not yet passed ACK time. Leaving it alone', $bug->id);
next
}
$log->debug(sprintf 'Bug %d has not been ACK\'d - adding a comment', $bug->id);
# add a comment, this will taint the bug's last_change_time
my %comment = (
id => $bug->id,
comment => sprintf(<<'EOF', $0, hostname(), $acktime)
No activity on new bug within %3$d hours of creation.
***Please tend to this issue urgently***
PLEASEACK: By %1$s running on %2$s
EOF
);
my $commentid = try {
return BZ::Client::Bug::Comment->add($client,\%comment)
}
catch {
$log->logdie(sprintf 'Something bad happened adding an ACK comment: %s',
Dumper( $_ ) );
};
$log->info(sprintf 'Added please ACK to Bug %d, comment id %d ', $bug->id, $commentid);
next
}
# if last_change_time >= stir time, then absolutely we need to do something
if ($now->delta_ms($bug->last_change_time)->in_units('hours') >= $stirtime ) {
$log->debug(sprintf 'Bug %d needs a stir - adding a comment', $bug->id);
# add a comment, this will taint the bug's last_change_time
my %comment = (
id => $bug->id,
comment => sprintf(<<'EOF', $0, hostname(), $stirtime)
Bug appears to have stalled, %3$d hours of inactivity.
***Please tend to this issue urgently***
STIRSTALLED: By %1$s running on %2$s
EOF
);
my $commentid = try {
return BZ::Client::Bug::Comment->add($client,\%comment)
}
catch {
$log->logdie(sprintf 'Something bad happened adding an stir comment: %s',
Dumper( $_ ) );
};
$log->info(sprintf 'Added a stir to Bug %d, comment id %d ', $bug->id, $commentid);
next
}
# FIXME, do something with bugs that are just being stired over and over
$log->debug(sprintf 'Bug %d is NEW/ASSIGNED but not yet ready for a stir. Leaving it alone', $bug->id);
}
}
$log->info('Finished stirring stalled bugs');
}
}
{
sub close_resolved {
$log->info('Going to close resolved bugs');
my %search = (
status => 'RESOLVED',
keywords => $team{keywords}
);
my @bugs = try {
return BZ::Client::Bug->search( $client, \%search )
}
catch {
$log->logdie(sprintf 'Something bad happened searching for RESOLVED bugs: %s',
Dumper( $_ ) );
};
if (@bugs) {
my $now = DateTime->now();
for my $bug (@bugs) {
( run in 3.111 seconds using v1.01-cache-2.11-cpan-2398b32b56e )