From e52abd49880e8eec7afe59d68ed6a69d5d5f6464 Mon Sep 17 00:00:00 2001 From: Nael Date: Thu, 13 Feb 2014 01:45:56 +0100 Subject: [PATCH] major db queries --- uVote/api/votes/votes.php | 13 ++-------- uVote/dbd/qq/UVOTE_DATA_BT_PER_POLL.php | 2 +- uVote/dbd/qq/UVOTE_DATA_PARTY_PER_POLL.php | 11 ++++++++ .../qq/UVOTE_DATA_USER_PER_PARTY_OVERALL.php | 15 +++++++++++ .../qq/UVOTE_DATA_USER_TO_PARTY_OVERALL.php | 15 +++++++++++ uVote/page/default_bulletin/bulletin.tpl | 25 +++++++++---------- .../default_bulletin/default_bulletin.php | 4 +-- uVote/page/default_bulletin/table_bt.tpl | 5 ++-- uVote/page/default_bulletin/table_parties.tpl | 1 + 9 files changed, 61 insertions(+), 30 deletions(-) create mode 100644 uVote/dbd/qq/UVOTE_DATA_PARTY_PER_POLL.php create mode 100644 uVote/dbd/qq/UVOTE_DATA_USER_PER_PARTY_OVERALL.php create mode 100644 uVote/dbd/qq/UVOTE_DATA_USER_TO_PARTY_OVERALL.php diff --git a/uVote/api/votes/votes.php b/uVote/api/votes/votes.php index cf43f0b..83ee18d 100644 --- a/uVote/api/votes/votes.php +++ b/uVote/api/votes/votes.php @@ -75,16 +75,7 @@ class votes { } public static function get_barsperparty($poll_ID){ - $con = new \SYSTEM\DB\Connection(new \DBD\uVote()); - $pbpp = array(); - $part = $con->prepare( 'selVoteByPoll_ID', - 'SELECT * FROM `uvote_votes_per_party` WHERE `poll_ID` = ?;', - array($poll_ID)); - - while ($result = $part->next()){ - $pbpp[] = $result;} - return $pbpp; - } + return \DBD\UVOTE_DATA_PARTY_PER_POLL::QA(array($poll_ID));} public static function write_vote($poll_ID, $vote){ if(!\SYSTEM\SECURITY\Security::isLoggedIn()){ @@ -99,7 +90,7 @@ class votes { $res = $con->prepare( 'insertVote', 'REPLACE uvote_data - VALUES (?, ?, ?, 0);', + VALUES (?, ?, ?, 0, NOW());', array($poll_ID, \SYSTEM\SECURITY\Security::getUser()->id, $vote)); return JsonResult::ok(); } diff --git a/uVote/dbd/qq/UVOTE_DATA_BT_PER_POLL.php b/uVote/dbd/qq/UVOTE_DATA_BT_PER_POLL.php index b2af6f8..acf9cd4 100644 --- a/uVote/dbd/qq/UVOTE_DATA_BT_PER_POLL.php +++ b/uVote/dbd/qq/UVOTE_DATA_BT_PER_POLL.php @@ -11,6 +11,6 @@ class UVOTE_DATA_BT_PER_POLL extends \SYSTEM\DB\QP { sum(votes_pro) as bt_pro, sum(votes_contra) as bt_con, sum(nr_attending) as bt_attending, - sum(total) as bt_total + sum(total) as bt_total FROM uvote_votes_per_party WHERE poll_ID = ?;' );}} \ No newline at end of file diff --git a/uVote/dbd/qq/UVOTE_DATA_PARTY_PER_POLL.php b/uVote/dbd/qq/UVOTE_DATA_PARTY_PER_POLL.php new file mode 100644 index 0000000..a0d0a19 --- /dev/null +++ b/uVote/dbd/qq/UVOTE_DATA_PARTY_PER_POLL.php @@ -0,0 +1,11 @@ + - -
- - ${vote_buttons} -
-
- -
+
${bars_user}
- +
+

Ergebnis Bundestag

+ ${bars_bt} +
+
+ + ${vote_buttons} +
+
+
-

Ergebnis der Fraktionen

${bars_party}
-
- ${bars_bt} -
\ No newline at end of file + \ No newline at end of file diff --git a/uVote/page/default_bulletin/default_bulletin.php b/uVote/page/default_bulletin/default_bulletin.php index 4dc0852..b143f0a 100644 --- a/uVote/page/default_bulletin/default_bulletin.php +++ b/uVote/page/default_bulletin/default_bulletin.php @@ -53,8 +53,8 @@ class default_bulletin extends SYSTEM\PAGE\Page { $poll_data[] = DBD\UVOTE_DATA_CHOICE_OVERALL::Q1(array(2)); $poll_data[] = DBD\UVOTE_DATA_CHOICE_OVERALL::Q1(array(3)); $vars = array(); - $vars['bars_party'] = $this->bars_party(); - $vars['bars_user'] = $poll_expired ? '' : $this->bars_user(); + $vars['bars_party'] = $poll_expired ? '' : $this->bars_party(); + $vars['bars_user'] = $this->bars_user(); $vars['bars_bt'] = $this->bars_bt(); $vars['js'] = $this->js(); $vars['css'] = $this->css(); diff --git a/uVote/page/default_bulletin/table_bt.tpl b/uVote/page/default_bulletin/table_bt.tpl index 9ac6950..ae6cacb 100644 --- a/uVote/page/default_bulletin/table_bt.tpl +++ b/uVote/page/default_bulletin/table_bt.tpl @@ -1,6 +1,5 @@ -
-

Ergebnis Bundestag

-
+
+

diff --git a/uVote/page/default_bulletin/table_parties.tpl b/uVote/page/default_bulletin/table_parties.tpl index d42008c..940c8a1 100644 --- a/uVote/page/default_bulletin/table_parties.tpl +++ b/uVote/page/default_bulletin/table_parties.tpl @@ -5,4 +5,5 @@ ${party}

+ ${choice}
\ No newline at end of file