$dbhost //= 'jira-dev';
$dbname //= 'bugzilla';
$dbuser //= 'adefaria';
- $dbpass //= 'reader';
-
+ $dbpass //= '********';
+
$main::log->msg ("Connecting to Bugzilla ($dbuser\@$dbhost)");
-
+
$bugzilla = DBI->connect (
"DBI:mysql:$dbname:$dbhost",
$dbuser,
RaiseError => 1,
},
);
-
+
_checkDBError 'Unable to execute statement', 'Connect';
return $bugzilla;
sub getBug ($;@) {
my ($bugid, @fields) = @_;
-
+
push @fields, 'short_desc' unless @fields;
-
+
my $statement = 'select ' . join (',', @fields) .
" from bugs where bug_id = $bugid";
-
+
my $sth = $bugzilla->prepare ($statement);
_checkDBError 'Unable to prepare statement', $statement;
-
+
_checkDBError 'Unable to execute statement', $statement;
$sth->execute;
sub getBugComments ($) {
my ($bugid) = @_;
-
+
my $statement = <<"END";
select
bug_id,
who = userid and
bug_id = $bugid
END
-
+
my $sth = $bugzilla->prepare ($statement);
-
+
_checkDBError 'Unable to prepare statement', $statement;
$sth->execute;
-
+
_checkDBError 'Unable to execute statement', $statement;
-
+
my @comments;
-
+
while (my $comment = $sth->fetchrow_hashref) {
my $commentText = <<"END";
The following comment was entered by [~$comment->{username}] on $comment->{bug_when}:
push @comments, $commentText;
} # while
-
+
return \@comments;
} # getBugComments
sub getRelationships ($$$$@) {
my ($table, $returnField, $testField, $relationshipType, @bugs) = @_;
-
+
$main::log->msg ("Getting $relationshipType");
-
+
my $statement = "select $returnField from $table where $table.$testField = ?";
my $sth = $bugzilla->prepare ($statement);
_checkDBError 'Unable to prepare statement', $statement;
-
+
my %relationships;
my %bugmap;
-
+
map {$bugmap{$_} = 1} @bugs unless %bugmap;
-
+
for my $bugid (@bugs) {
$sth->execute ($bugid);
-
+
_checkDBError 'Unable to exit statement', $statement;
-
+
my $result = JIRAUtils::findIssue ($bugid, %bugmap);
-
+
if ($result =~ /^Unable/) {
$main::log->warn ($result);
-
+
$main::total{'Missing JIRA Issues'}++;
-
+
undef $result;
} elsif ($result =~ /^Future/) {
$main::total{'Future JIRA Issues'}++;
-
+
undef $result;
} # if
-
+
my $jiraIssue = $result;
my $key = $jiraIssue || $bugid;
my @relationships;
my $relations = $sth->fetchall_arrayref;
my @relations;
-
+
map {push @relations, $_->[0]} @$relations;
-
+
for my $relation (@relations) {
$jiraIssue = JIRAUtils::findIssue ($relation);
-
+
if ($jiraIssue =~ /^Unable/ || $jiraIssue =~ /^Future/) {
$main::log->warn ($jiraIssue);
$main::total{'Missing JIRA Issues'}++ if $jiraIssue =~ /^Unable/;
$main::total{'Future JIRA Issues'}++ if $jiraIssue =~ /^Future/;
-
+
push @relationships, $relation;
} else {
push @relationships, $jiraIssue;
} # if
} # for
-
+
push @{$relationships{$key}}, @relationships if @relationships;
} # for
-
+
$main::total{$relationshipType} = keys %relationships;
-
+
return \%relationships;
} # getRelationships
sub getBlockers (@) {
my (@bugs) = @_;
-
+
return getRelationships (
'dependencies',
'blocked',
sub getRelated (@) {
my (@bugs) = @_;
-
+
return getRelationships (
'bug_see_also',
'value',
sub getWatchers ($) {
my ($bugid) = @_;
-
+
my $statement = <<"END";
select
profiles.login_name