[aur-dev] [PATCH 2/2] Update vote participation if a TU becomes active
Lukas Fleischer
archlinux at cryptocrack.de
Mon Aug 5 17:43:01 EDT 2013
Instead of computing vote participation at the beginning of a vote only,
update the number of active TUs whenever a TU becomes active during the
voting period.
A TU is considered active (with regard to a specific vote) if there
exists a point in time during the voting period when he is active.
Signed-off-by: Lukas Fleischer <archlinux at cryptocrack.de>
---
web/lib/acctfuncs.inc.php | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php
index 3f7b595..3a4ff51 100644
--- a/web/lib/acctfuncs.inc.php
+++ b/web/lib/acctfuncs.inc.php
@@ -287,6 +287,23 @@ function process_account_form($UTYPE,$TYPE,$A,$U="",$T="",$S="",$E="",
print __("The account, %s%s%s, has been successfully modified.",
"<strong>", htmlspecialchars($U,ENT_QUOTES), "</strong>");
}
+
+ if ($T == 2 && $inactivity_ts == 0) {
+ /*
+ * A (new) TU became active -- add him to the
+ * active TU list for all running votes.
+ */
+ $q = "INSERT INTO TU_VoteActive (UserID, ";
+ $q.= "VoteID) SELECT " . intval($UID) . " ";
+ $q.= "AS UserID, ID AS VoteID FROM ";
+ $q.= "TU_VoteInfo WHERE End >= ";
+ $q.= "UNIX_TIMESTAMP() AND NOT EXISTS (";
+ $q.= "SELECT * FROM TU_VoteActive WHERE ";
+ $q.= "TU_VoteActive.UserID = " . intval($UID);
+ $q.= " AND TU_VoteActive.VoteID = ";
+ $q.= "TU_VoteInfo.ID)";
+ $dbh->exec($q);
+ }
}
}
return;
--
1.8.4.rc1.383.g13e9f3f
More information about the aur-dev
mailing list