Huji has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/310382

Change subject: Show statistics above teh list of votes
......................................................................

Show statistics above teh list of votes

Bug: T145542
Change-Id: I807b2f083873c332eaebe8eb74b3ada08e90574b
---
M i18n/en.json
M i18n/qqq.json
M includes/pages/ListPage.php
3 files changed, 50 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SecurePoll 
refs/changes/82/310382/1

diff --git a/i18n/en.json b/i18n/en.json
index 17d28c3..b12eddd 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -254,6 +254,8 @@
        "right-securepoll-create-poll": "Create polls",
        "action-securepoll-create-poll": "create polls",
        "securepoll-ns-readonly": "The {{ns:SecurePoll}} namespace is 
read-only",
+       "securepoll-voter-stats": "Out of all eligible voters, $1 
{{PLURAL:$1|voter has|voters have}} voted.",
+       "securepoll-vote-stats": "A total of $1 {{PLURAL:$1|vote has|votes 
have}} been cast. Of these, $2 {{PLURAL:$2|is|are}} thrown away because the 
voter has voted again, and $3 {{PLURAL:$3|is|are}} struk.",
        "apihelp-strikevote-description": "Allows admins to strike or unstrike 
a vote.",
        "apihelp-strikevote-param-option": "Which action to take: strike or 
unstrike a vote.",
        "apihelp-strikevote-paramvalue-option-strike": "Strike a vote (remove 
it from the count).",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 747e5b5..45f7215 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -235,6 +235,8 @@
        "right-securepoll-create-poll": "{{doc-right|securepoll-create-poll}}",
        "action-securepoll-create-poll": 
"{{Doc-action|securepoll-create-poll}}",
        "securepoll-ns-readonly": "Error message to inform the user that the 
SecurePoll namespace cannot be edited.",
+       "securepoll-voter-stats": "Explanation of the unique number of voters 
who participated in the election; shown above the vote list.",
+       "securepoll-vote-stats": "Explanation of the total number of votes 
cast, as well as the number that were excluded because the voter had voted 
again, and the number that have been struck by an election admin; shown above 
the vote list.",
        "apihelp-strikevote-description": 
"{{doc-apihelp-description|strikevote}}",
        "apihelp-strikevote-param-option": 
"{{doc-apihelp-param|strikevote|option}}",
        "apihelp-strikevote-paramvalue-option-strike": 
"{{doc-apihelp-paramvalue|strikevote|option|strike}}",
diff --git a/includes/pages/ListPage.php b/includes/pages/ListPage.php
index cd9fcf5..15e6742 100644
--- a/includes/pages/ListPage.php
+++ b/includes/pages/ListPage.php
@@ -37,6 +37,52 @@
                        return;
                }
 
+               $dbw = $this->election->context->getDB();
+
+               $res = $dbw->select(
+                       'securepoll_votes',
+                       array( 'DISTINCT vote_voter' ),
+                       array(
+                               'vote_election' => $this->election->getID()
+                       )
+               );
+               $distinct_voters = $res->result->num_rows;
+
+               $res = $dbw->select(
+                       'securepoll_votes',
+                       array( 'vote_id' ),
+                       array(
+                               'vote_election' => $this->election->getID()
+                       )
+               );
+               $all_votes = $res->result->num_rows;
+
+               $res = $dbw->select(
+                       'securepoll_votes',
+                       array( 'vote_id' ),
+                       array(
+                               'vote_election' => $this->election->getID(),
+                               'vote_current' => 0
+                       )
+               );
+               $not_current_votes = $res->result->num_rows;
+
+               $res = $dbw->select(
+                       'securepoll_votes',
+                       array( 'vote_id' ),
+                       array(
+                               'vote_election' => $this->election->getID(),
+                               'vote_struck' => 1
+                       )
+               );
+               $struck_votes = $res->result->num_rows;
+
+               $out->addHTML('<div id="mw-poll-stats"><p>' .
+                       $this->msg( 'securepoll-voter-stats', $distinct_voters 
) .
+                       '</p><p>' .
+                       $this->msg( 'securepoll-vote-stats', $all_votes, 
$not_current_votes, $struck_votes ) .
+                       '</p></div>');
+
                $pager = new SecurePoll_ListPager( $this );
                $out->addHTML(
                        $pager->getLimitForm() .

-- 
To view, visit https://gerrit.wikimedia.org/r/310382
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I807b2f083873c332eaebe8eb74b3ada08e90574b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SecurePoll
Gerrit-Branch: master
Gerrit-Owner: Huji <huji.h...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to