Alexander Nicolaysen Sørnes : Cache whether an app is maintained

Alexander Nicolaysen Sørnes asornes at winehq.org
Thu Nov 12 03:40:07 CST 2009


Module: appdb
Branch: master
Commit: dacc985d984fa0c87c1893b7fba9eafa153848b6
URL:    http://source.winehq.org/git/appdb.git/?a=commit;h=dacc985d984fa0c87c1893b7fba9eafa153848b6

Author: Alexander Nicolaysen Sørnes <alexander at linux-xqqm.(none)>
Date:   Wed Nov 11 22:22:35 2009 +0100

Cache whether an app is maintained

---

 include/application.php |    9 +++++++++
 include/maintainer.php  |   25 +++++++++++++++++++++++++
 tables/appdb_tables.sql |    1 +
 3 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/include/application.php b/include/application.php
index 256afa1..3251261 100644
--- a/include/application.php
+++ b/include/application.php
@@ -39,6 +39,7 @@ class Application {
     var $sSubmitTime;
     var $iSubmitterId;
     var $aVersionsIds;  // an array that contains the versionId of every version linked to this app.
+    var $bHasMaintainer;
     var $aVersions; // Array of version objects belonging to this app
     var $iMaintainerRequest; /* Temporary variable for tracking maintainer
                                 requests on app submission.  Value denotes type of request */
@@ -78,6 +79,7 @@ class Application {
             // and return an id into the appData table here
             $this->sWebpage = Url::normalize($oRow->webPage);
             $this->sState = $oRow->state;
+            $this->bHasMaintainer = $oRow->hasMaintainer == 'true' ? true : false;
         }
 
         /* fetch versions of this application, if there are any */
@@ -242,6 +244,13 @@ class Application {
         return true;
     }
 
+    public function updateMaintainerState()
+    {
+        $this->bHasMaintainer = maintainer::appHasMaintainer($this->iAppId);
+
+        $hResult = query_parameters("UPDATE appFamily SET hasMaintainer = '?' WHERE appId = '?'", $this->bHasMaintainer ? 'true' : 'false', $this->iAppId);
+    }
+
     /**
     * Deletes the application from the database. 
     * and request the deletion of linked elements.
diff --git a/include/maintainer.php b/include/maintainer.php
index 3a39729..489bafb 100644
--- a/include/maintainer.php
+++ b/include/maintainer.php
@@ -229,6 +229,9 @@ class maintainer
         /* this objects id is the insert id returned by the database */
         $this->iMaintainerId = query_appdb_insert_id();
 
+        if(!$this->mustBeQueued())
+            $this->updateAppMaintainerState();
+
         /* If this is a non-queued maintainer submission, remove the user's non-
            super maintainer entries for the application's versions.  This check is
            also done in unQueue() */
@@ -257,6 +260,8 @@ class maintainer
             {
                 $sStatusMessage = "<p>The maintainer was successfully added into the database</p>\n";
 
+                $this->updateAppMaintainerState();
+
                 //Send Status Email
                 $sEmail = $oUser->sEmail;
                 if ($sEmail)
@@ -348,6 +353,8 @@ class maintainer
         if(!$hResult)
             return FALSE;
 
+        $this->updateAppMaintainerState();
+
         return TRUE;
     }
 
@@ -406,6 +413,12 @@ class maintainer
         return $hResult;
     }
 
+    public function updateAppMaintainerState()
+    {
+        $oApp = new application($this->iAppId);
+        $oApp->updateMaintainerState();
+    }
+
     function getSubmitterEmails()
     {
         $sRecipients = '';
@@ -587,6 +600,18 @@ class maintainer
         return query_num_rows($hResult);
     }
 
+    /* Returns true if the given app has a maintainer, false otherwise */
+    public function appHasMaintainer($iAppId)
+    {
+        $hResult = query_parameters("SELECT COUNT(maintainerId) as count FROM appMaintainers WHERE appId = '?' AND superMaintainer = '1' AND state = 'accepted'", $iAppId);
+
+        if(!$hResult)
+            return false;
+
+        $oRow = mysql_fetch_object($hResult);
+        return $oRow->count > 0;
+    }
+
     /* if given an appid or a version id return a handle for a query that has */
     /* the user ids that are maintainers for this particular appid or version id */
     function getMaintainersForAppIdVersionId($iAppId = null, $iVersionId = null)
diff --git a/tables/appdb_tables.sql b/tables/appdb_tables.sql
index f41c5fd..69ab049 100644
--- a/tables/appdb_tables.sql
+++ b/tables/appdb_tables.sql
@@ -41,6 +41,7 @@ create table appFamily (
 	submitTime    datetime NOT NULL,
 	submitterId   int(11) NOT NULL default '0',
 	state         enum('accepted','queued','rejected','deleted') NOT NULL default 'accepted',
+	hasMaintainer enum('true','false') NOT NULL default 'false',
 	key(appId)
 );
 




More information about the wine-cvs mailing list