diff options
author | terry%mozilla.org <> | 1999-10-12 02:14:30 +0200 |
---|---|---|
committer | terry%mozilla.org <> | 1999-10-12 02:14:30 +0200 |
commit | 73627e594d61e4606b57880cb35bdc50efb3e900 (patch) | |
tree | 329975a02b727ff925fdf1b4aae13b942bd2014c /doeditvotes.cgi | |
parent | 76965a12c5f49e9a6bf99ea0f2d88ba0852bab3d (diff) | |
download | bugzilla-73627e594d61e4606b57880cb35bdc50efb3e900.tar.gz bugzilla-73627e594d61e4606b57880cb35bdc50efb3e900.tar.xz |
Added a "votes" field to the bugs table, which caches the total number
of votes that have been cast for that bug. This let me simplify the
SQL in buglist.cgi, which makes things more efficient and fixes
several strange bugs.
Diffstat (limited to 'doeditvotes.cgi')
-rwxr-xr-x | doeditvotes.cgi | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/doeditvotes.cgi b/doeditvotes.cgi index 03c4c1d88..c499af494 100755 --- a/doeditvotes.cgi +++ b/doeditvotes.cgi @@ -86,12 +86,28 @@ foreach my $prod (keys(%prodcount)) { } } +my %affected; +SendSQL("lock tables bugs write, votes write"); +SendSQL("select bug_id from votes where who = $who"); +while (MoreSQLData()) { + my $id = FetchOneColumn(); + $affected{$id} = 1; +} SendSQL("delete from votes where who = $who"); foreach my $id (@buglist) { if ($::FORM{$id} > 0) { SendSQL("insert into votes (who, bug_id, count) values ($who, $id, $::FORM{$id})"); } + $affected{$id} = 1; +} +foreach my $id (keys %affected) { + SendSQL("select sum(count) from votes where bug_id = $id"); + my $v = FetchOneColumn(); + SendSQL("update bugs set votes = $v where bug_id = $id"); } +SendSQL("unlock tables"); + + PutHeader("Voting tabulated", "Voting tabulated", $::COOKIE{'Bugzilla_login'}); print "Your votes have been recorded.\n"; |