[aur-dev] [PATCH 2/3] Store the number of active TUs when starting a vote

Lukas Fleischer archlinux at cryptocrack.de
Sun Aug 4 09:27:45 EDT 2013


This will be used for automated calculation of vote participation later.

Signed-off-by: Lukas Fleischer <archlinux at cryptocrack.de>
---
 UPGRADING                     |  7 +++++++
 support/schema/aur-schema.sql |  1 +
 web/lib/acctfuncs.inc.php     | 11 +++++++++--
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/UPGRADING b/UPGRADING
index d8527e3..307ed8d 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -10,6 +10,13 @@ From 2.2.0 to 2.3.0
 ALTER TABLE Users ADD COLUMN InactivityTS BIGINT NOT NULL DEFAULT 0;
 ----
 
+2. Add a field to store the number of active TUs to the "TU_VoteInfo" table:
+
+----
+ALTER TABLE TU_VoteInfo
+	ADD COLUMN ActiveTUs tinyint(3) unsigned NOT NULL default '0';
+----
+
 From 2.1.0 to 2.2.0
 -------------------
 
diff --git a/support/schema/aur-schema.sql b/support/schema/aur-schema.sql
index 68db93f..51f9601 100644
--- a/support/schema/aur-schema.sql
+++ b/support/schema/aur-schema.sql
@@ -202,6 +202,7 @@ CREATE TABLE IF NOT EXISTS TU_VoteInfo (
   Yes tinyint(3) unsigned NOT NULL default '0',
   No tinyint(3) unsigned NOT NULL default '0',
   Abstain tinyint(3) unsigned NOT NULL default '0',
+  ActiveTUs tinyint(3) unsigned NOT NULL default '0',
   PRIMARY KEY  (ID),
   FOREIGN KEY (SubmitterID) REFERENCES Users(ID) ON DELETE CASCADE
 ) ENGINE = InnoDB;
diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php
index 7602ec2..6fe70af 100644
--- a/web/lib/acctfuncs.inc.php
+++ b/web/lib/acctfuncs.inc.php
@@ -618,10 +618,17 @@ function open_user_proposals($user) {
 function add_tu_proposal($agenda, $user, $votelength, $submitteruid) {
 	$dbh = DB::connect();
 
-	$q = "INSERT INTO TU_VoteInfo (Agenda, User, Submitted, End, SubmitterID) VALUES ";
+	$q = "SELECT COUNT(*) FROM Users WHERE AccountTypeID = 2 AND ";
+	$q.= "InactivityTS = 0";
+	$result = $dbh->query($q);
+	$row = $result->fetch(PDO::FETCH_NUM);
+	$active_tus = $row[0];
+
+	$q = "INSERT INTO TU_VoteInfo (Agenda, User, Submitted, End, ";
+	$q.= "SubmitterID, ActiveTUs) VALUES ";
 	$q.= "(" . $dbh->quote($agenda) . ", " . $dbh->quote($user) . ", ";
 	$q.= "UNIX_TIMESTAMP(), UNIX_TIMESTAMP() + " . $dbh->quote($votelength);
-	$q.= ", " . $submitteruid . ")";
+	$q.= ", " . $submitteruid . ", " . $active_tus . ")";
 	$result = $dbh->exec($q);
 }
 
-- 
1.8.4.rc1.383.g13e9f3f



More information about the aur-dev mailing list