Changeset 195
- Timestamp:
- 04/14/09 20:02:56 (15 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Vote/DB/Ballot.pm
r171 r195 65 65 66 66 my $sth = $self->db->prepare_cached( 67 q{select *, value as v from ballot_item where id = ?} 67 q{ 68 select ballot_item.*, value as v, 69 coalesce(ballot_map.to, corrected) as corrected 70 from ballot_item join ballot on ballot.id = ballot_item.id 71 left join ballot_map on ballot_map.poll = ballot.poll and 72 ballot_map.from = ballot_item.value 73 where ballot.id = ? 74 } 68 75 ); 69 76 $sth->execute($self->ballotid); -
trunk/lib/Vote/DB/Poll/Results.pm
r193 r195 67 67 sub results_count { 68 68 my ($self) = @_; 69 $self->_results(); 70 } 71 72 sub results_nonull { 73 my ($self) = @_; 74 $self->_results(1); 75 } 76 77 sub _results { 78 my ($self, $nonull) = @_; 69 79 70 80 my $sth = $self->db->prepare( 71 81 q{ 72 82 select count(ballot.id), value from 73 (select ballot.id, coalesce(corrected, value) as "value" from ballot left join ballot_item 74 on ballot.id = ballot_item.id where ballot.poll = ? and (invalid = 'false' or invalid is null) 75 group by ballot.id, coalesce(corrected, value)) as ballot 83 (select ballot.id, coalesce(corrected, ballot_map.to, value) as "value" from ballot 84 } . ($nonull ? '' : ' left ') . q{ 85 join ballot_item 86 on ballot.id = ballot_item.id 87 left join ballot_map on ballot.poll = ballot_map.poll and ballot_map.from = ballot_item.value 88 where ballot.poll = ? and (invalid = 'false' or invalid is null) 89 group by ballot.id, coalesce(corrected, ballot_map.to, value)) as ballot 76 90 group by value 77 91 order by count desc, value … … 85 99 \@results; 86 100 } 87 88 sub results_nonull {89 my ($self) = @_;90 91 my $sth = $self->db->prepare(92 q{93 select count(ballot.id), value from94 (select ballot.id, coalesce(corrected, value) as "value" from ballot join ballot_item95 on ballot.id = ballot_item.id where ballot.poll = ? and (invalid = 'false' or invalid is null)96 group by ballot.id, coalesce(corrected, value)) as ballot97 group by value98 order by count desc, value99 }100 );101 $sth->execute($self->voteid);102 my @results;103 while (my $res = $sth->fetchrow_hashref) {104 push(@results, $res);105 }106 \@results;107 }108 109 101 110 102 =head1 AUTHOR
Note: See TracChangeset
for help on using the changeset viewer.