From 5ce0b3db0853855466b43a011ce0b964e837c1b5 Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Tue, 15 Aug 2006 01:04:39 +0000 Subject: Bug 324296: Bugzilla::Bug->vote_count should be its own subroutine Max Kanat-Alexander r=LpSolit, a=justdave --- Bugzilla/Bug.pm | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'Bugzilla/Bug.pm') diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 03be7156c..06c1f4bfe 100755 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -108,29 +108,18 @@ sub _init { bug_file_loc, short_desc, target_milestone, qa_contact AS qa_contact_id, status_whiteboard, " . $dbh->sql_date_format('creation_ts', '%Y.%m.%d %H:%i') . ", - delta_ts, COALESCE(SUM(votes.vote_count), 0), everconfirmed, - reporter_accessible, cclist_accessible, + delta_ts, everconfirmed, reporter_accessible, cclist_accessible, estimated_time, remaining_time, " . $dbh->sql_date_format('deadline', '%Y-%m-%d') . $custom_fields . " FROM bugs - LEFT JOIN votes - ON bugs.bug_id = votes.bug_id INNER JOIN components ON components.id = bugs.component_id INNER JOIN products ON products.id = bugs.product_id INNER JOIN classifications ON classifications.id = products.classification_id - WHERE bugs.bug_id = ? " . - $dbh->sql_group_by('bugs.bug_id', "alias, products.classification_id, - classifications.name, bugs.product_id, products.name, version, - rep_platform, op_sys, bug_status, resolution, priority, - bug_severity, bugs.component_id, components.name, assigned_to, - reporter, bug_file_loc, short_desc, target_milestone, - qa_contact, status_whiteboard, everconfirmed, creation_ts, - delta_ts, reporter_accessible, cclist_accessible, - estimated_time, remaining_time, deadline $custom_fields"); + WHERE bugs.bug_id = ?"; my $bug_sth = $dbh->prepare($query); $bug_sth->execute($bug_id); @@ -146,7 +135,7 @@ sub _init { "assigned_to_id", "reporter_id", "bug_file_loc", "short_desc", "target_milestone", "qa_contact_id", "status_whiteboard", - "creation_ts", "delta_ts", "votes", "everconfirmed", + "creation_ts", "delta_ts", "everconfirmed", "reporter_accessible", "cclist_accessible", "estimated_time", "remaining_time", "deadline", Bugzilla->custom_field_names) @@ -658,6 +647,20 @@ sub settable_resolutions { return $resolutions; } +sub votes { + my ($self) = @_; + return 0 if $self->{error}; + return $self->{votes} if defined $self->{votes}; + + my $dbh = Bugzilla->dbh; + $self->{votes} = $dbh->selectrow_array( + 'SELECT SUM(vote_count) FROM votes + WHERE bug_id = ? ' . $dbh->sql_group_by('bug_id'), + undef, $self->bug_id); + $self->{votes} ||= 0; + return $self->{votes}; +} + # Convenience Function. If you need speed, use this. If you need # other Bug fields in addition to this, just create a new Bug with # the alias. -- cgit v1.2.3-24-g4f1b