Alexander Nicolaysen Sørnes : cron: Add a script to remove votes for deleted versions
Alexander Nicolaysen Sørnes
asornes at winehq.org
Wed Jul 22 10:07:58 CDT 2009
Module: appdb
Branch: master
Commit: 95d93a09c2d7ae8a8c2f4f33e462c22ec9130048
URL: http://source.winehq.org/git/appdb.git/?a=commit;h=95d93a09c2d7ae8a8c2f4f33e462c22ec9130048
Author: Alexander Nicolaysen Sørnes <alex at thehandofagony.com>
Date: Wed Jul 22 17:07:35 2009 +0200
cron: Add a script to remove votes for deleted versions
---
cron/cleanup.php | 42 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/cron/cleanup.php b/cron/cleanup.php
index 7c1fb25..79b7173 100644
--- a/cron/cleanup.php
+++ b/cron/cleanup.php
@@ -28,6 +28,9 @@ removeScreenshotsWithMissingFiles();
/* status since they aren't really maintaining the application/version */
maintainerCheck();
+/* remove votes for versions that have been deleted */
+cleanupVotes();
+
/* Updates the rating info for all versions based on test results */
//updateRatings();
@@ -294,6 +297,45 @@ function maintainerCheck()
maintainer::notifyMaintainersOfQueuedData();
}
+/* remove votes for versions that have been deleted */
+function cleanupVotes()
+{
+ $hResult = mysql_query("SELECT appVotes.* FROM appVotes,appVersion WHERE
+ appVotes.versionId = appVersion.versionId
+ AND appVersion.state = 'deleted'");
+
+ if(!$hResult)
+ return;
+
+ $iDeleted = 0;
+ $iFailed = 0;
+
+ while($oRow = mysql_fetch_object($hResult))
+ {
+ $oVote = new vote(null, $oRow);
+ if($oVote->delete())
+ $iDeleted++;
+ else
+ $iFailed++;
+ }
+
+ $sEmails = user::get_notify_email_address_list(null, null); // only admins
+
+ if($sEmails)
+ {
+ global $sEmailSubject;
+ $sSubject = $sEmailSubject . 'Vote Cleanup';
+ $sPlural = ($iDeleted == 1) ? '' : 's';
+ $sMsg = "Removed $iDeleted vote$sPlural cast for deleted versions\n";
+ if($iFailed)
+ {
+ $sPlural = ($iFailed == 1) ? '' : 's';
+ $sMsg .= "WARNING: Failed to delete $iFailed vote$sPlural\n";
+ }
+ mail_appdb($sEmails, $sSubject, $sMsg);
+ }
+}
+
function updateRatings()
{
$hResult = query_parameters("SELECT * FROM appVersion");
More information about the wine-cvs
mailing list