Changeset 193
- Timestamp:
- 04/14/09 18:19:40 (15 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MANIFEST
r183 r193 25 25 lib/Vote/DB/common.pm 26 26 lib/Vote/DB/Poll.pm 27 lib/Vote/DB/Poll/Results.pm 27 28 lib/Vote/DB/Voting.pm 28 29 lib/Vote/DB/Ballot.pm -
trunk/lib/Vote/DB.pm
r182 r193 8 8 use base 'Vote::DB::common'; 9 9 use Vote::DB::Poll; 10 use Vote::DB::Poll::Results; 10 11 use Vote::DB::Ballot; # see ballot() 11 12 use Vote::DB::Voting; # see delete_voting() … … 93 94 } 94 95 96 sub results { 97 my ($self, $pollid) = @_; 98 Vote::DB::Poll::Results->new($self->{dbstring}, $pollid); 99 } 100 95 101 sub ballot { 96 102 my ($self, $ballotid) = @_; … … 194 200 sub vote_ballot_count_nonull { 195 201 my ($self, $voteid) = @_; 196 $self-> poll($voteid)->ballot_count_nonull;202 $self->results($voteid)->ballot_count_nonull; 197 203 } 198 204 … … 217 223 sub vote_results_count { 218 224 my ($self, $voteid) = @_; 219 $self-> poll($voteid)->results_count;225 $self->results($voteid)->results_count; 220 226 } 221 227 222 228 sub vote_results_nonull { 223 229 my ($self, $voteid) = @_; 224 $self-> poll($voteid)->results_nonull;230 $self->results($voteid)->results_nonull; 225 231 } 226 232 -
trunk/lib/Vote/DB/Poll.pm
r191 r193 527 527 } 528 528 529 sub ballot_count_nonull {530 my ($self) = @_;531 532 my $sth = $self->db->prepare_cached(533 q{534 select count(*) from ballot where poll = ?535 and id in (select id from ballot_item) and536 (invalid = 'false' or invalid is null)537 }538 );539 540 $sth->execute($self->voteid);541 my $res = $sth->fetchrow_hashref;542 $sth->finish;543 $res->{count}544 }545 546 529 sub voting_info_id { 547 530 my ($self, $mail) = @_; … … 601 584 602 585 return 1; 603 }604 605 sub results_count {606 my ($self) = @_;607 608 my $sth = $self->db->prepare(609 q{610 select count(ballot.id), value from611 (select ballot.id, coalesce(corrected, value) as "value" from ballot left join ballot_item612 on ballot.id = ballot_item.id where ballot.poll = ? and (invalid = 'false'or invalid is null)613 group by ballot.id, coalesce(corrected, value)) as ballot614 group by value615 order by count desc, value616 }617 );618 $sth->execute($self->voteid);619 my @results;620 while (my $res = $sth->fetchrow_hashref) {621 push(@results, $res);622 }623 @results;624 }625 626 sub results_nonull {627 my ($self) = @_;628 629 my $sth = $self->db->prepare(630 q{631 select count(ballot.id), value from632 (select ballot.id, coalesce(corrected, value) as "value" from ballot join ballot_item633 on ballot.id = ballot_item.id where ballot.poll = ? and (invalid = 'false'or invalid is null)634 group by ballot.id, coalesce(corrected, value)) as ballot635 group by value636 order by count desc, value637 }638 );639 $sth->execute($self->voteid);640 my @results;641 while (my $res = $sth->fetchrow_hashref) {642 push(@results, $res);643 }644 \@results;645 586 } 646 587 -
trunk/root/latex/poll_report.tt
r188 r193 1 1 [% USE Mail %] 2 [%- poll = c.model('Vote'). poll(voteid) %]2 [%- poll = c.model('Vote').results(voteid) %] 3 3 4 4 \maketitle … … 54 54 55 55 [%- IF loop.count <= poll.info.choice_count -%] 56 [%- IF res.count >= poll. ballot_count_nonull / 2 + 1-%]56 [%- IF res.count >= poll.absolute_majority -%] 57 57 [%- comment = 'majorité absolue' -%] 58 58 [%- ELSE -%] -
trunk/root/templates/includes/poll_results.tt
r183 r193 43 43 [% mycount = loop.count %] 44 44 [% IF loop.count <= vote.vote_info(voteid).choice_count %] 45 [% IF res.count >= vote. ballot_count_nonull(voteid) / 2 + 1%]45 [% IF res.count >= vote.absolute_majority %] 46 46 [% class = 'majabs' %] 47 47 [% ELSE %]
Note: See TracChangeset
for help on using the changeset viewer.