Changeset 193 for trunk/lib/Vote/DB


Ignore:
Timestamp:
04/14/09 18:19:40 (15 years ago)
Author:
nanardon
Message:
  • add new objects for poll results
Location:
trunk/lib/Vote/DB
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Vote/DB/Poll.pm

    r191 r193  
    527527} 
    528528 
    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) and 
    536         (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  
    546529sub voting_info_id { 
    547530    my ($self, $mail) = @_; 
     
    601584 
    602585    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 from  
    611         (select ballot.id, coalesce(corrected, value) as "value" from ballot left join ballot_item 
    612         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 ballot 
    614         group by value 
    615         order by count desc, value 
    616         } 
    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 from  
    632         (select ballot.id, coalesce(corrected, value) as "value" from ballot join ballot_item 
    633         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 ballot 
    635         group by value 
    636         order by count desc, value 
    637         } 
    638     ); 
    639     $sth->execute($self->voteid); 
    640     my @results; 
    641     while (my $res = $sth->fetchrow_hashref) { 
    642         push(@results, $res); 
    643     } 
    644     \@results; 
    645586} 
    646587 
Note: See TracChangeset for help on using the changeset viewer.