[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

abarth at webkit.org abarth at webkit.org
Thu Apr 8 00:43:50 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 28d07bde40c2e4d5dcc1063327f1b816bd3d9983
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sun Dec 20 08:27:50 2009 +0000

    2009-12-20  Adam Barth  <abarth at webkit.org>
    
            Reviewed by Eric Seidel.
    
            Use memcache to make dashboard to fast
            https://bugs.webkit.org/show_bug.cgi?id=32780
    
            * QueueStatusServer/app.yaml:
            * QueueStatusServer/handlers/dashboard.py:
            * QueueStatusServer/handlers/updatestatus.py:
            * QueueStatusServer/model/attachment.py: Added.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52404 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 358a366..182b28b 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,15 @@
+2009-12-20  Adam Barth  <abarth at webkit.org>
+
+        Reviewed by Eric Seidel.
+
+        Use memcache to make dashboard to fast
+        https://bugs.webkit.org/show_bug.cgi?id=32780
+
+        * QueueStatusServer/app.yaml:
+        * QueueStatusServer/handlers/dashboard.py:
+        * QueueStatusServer/handlers/updatestatus.py:
+        * QueueStatusServer/model/attachment.py: Added.
+
 2009-12-19  Brent Fulgham  <bfulgham at webkit.org>
 
         Reviewed by Adam Roben.
diff --git a/WebKitTools/QueueStatusServer/app.yaml b/WebKitTools/QueueStatusServer/app.yaml
index f6ff870..76d8963 100644
--- a/WebKitTools/QueueStatusServer/app.yaml
+++ b/WebKitTools/QueueStatusServer/app.yaml
@@ -7,5 +7,9 @@ handlers:
 - url: /stylesheets
   static_dir: stylesheets
 
+- url: /remote_api
+  script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py
+  login: admin
+
 - url: /.*
   script: main.py
diff --git a/WebKitTools/QueueStatusServer/handlers/dashboard.py b/WebKitTools/QueueStatusServer/handlers/dashboard.py
index fd811b5..80f30ec 100644
--- a/WebKitTools/QueueStatusServer/handlers/dashboard.py
+++ b/WebKitTools/QueueStatusServer/handlers/dashboard.py
@@ -26,66 +26,16 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-import re
-
 from google.appengine.ext import webapp
 from google.appengine.ext.webapp import template
 
-from model.queuestatus import QueueStatus
-from handlers.statusbubble import StatusSummary
-
-queues = [
-    "style-queue",
-    "chromium-ews",
-    "qt-ews",
-    "gtk-ews",
-]
-
-def dash_to_underscore(dashed_name):
-    regexp = re.compile("-")
-    return regexp.sub("_", dashed_name)
-
-def state_from_status(status):
-    table = {
-        "Pass" : "pass",
-        "Fail" : "fail",
-    }
-    return table.get(status.message, "none")
-
-def summarize(attachment_id):
-    summary = { "attachment_id" : attachment_id }
-
-    # FIXME: We shouldn't have to make another query to figure this out.
-    #        We'll fix this with memcache.  Notice that we can't grab it
-    #        below because the patch might not have been processed by one
-    #        these queues yet.
-    summary["bug_id"] = QueueStatus.all().filter('active_patch_id =', attachment_id).fetch(1)[0].active_bug_id
-
-    for queue in queues:
-        summary[queue] = None
-        status = QueueStatus.all().filter('queue_name =', queue).filter('active_patch_id =', attachment_id).order('-date').get()
-        if status:
-            summary[dash_to_underscore(queue)] = {
-                "state" : state_from_status(status),
-                "status" : status,
-            }
-    return summary
-
+from model.attachment import Attachment
 
 class Dashboard(webapp.RequestHandler):
     def get(self):
-        status_summary = StatusSummary()
-        statuses = QueueStatus.all().order("-date")
-
-        attachment_ids = set()
-        for status in statuses:
-            if not status.active_patch_id:
-                continue
-            attachment_ids.add(status.active_patch_id)
-            if len(attachment_ids) >= 25:
-                break
+        attachments = Attachment.recent(limit=25)
 
         template_values = {
-            "summaries" : map(summarize, sorted(attachment_ids)),
+            "summaries" : [attachment.summary() for attachment in attachments],
         }
         self.response.out.write(template.render("templates/dashboard.html", template_values))
diff --git a/WebKitTools/QueueStatusServer/handlers/updatestatus.py b/WebKitTools/QueueStatusServer/handlers/updatestatus.py
index b81041a..3ad7b77 100644
--- a/WebKitTools/QueueStatusServer/handlers/updatestatus.py
+++ b/WebKitTools/QueueStatusServer/handlers/updatestatus.py
@@ -30,6 +30,7 @@ from google.appengine.api import users
 from google.appengine.ext import webapp, db
 from google.appengine.ext.webapp import template
 
+from model.attachment import Attachment
 from model.queuestatus import QueueStatus
 
 
@@ -52,12 +53,15 @@ class UpdateStatus(webapp.RequestHandler):
         if users.get_current_user():
             queue_status.author = users.get_current_user()
 
-        queue_name = self.request.get('queue_name')
+        bug_id = self._int_from_request("bug_id")
+        patch_id = self._int_from_request("patch_id")
+        queue_name = self.request.get("queue_name")
         queue_status.queue_name = queue_name
-        queue_status.active_bug_id = self._int_from_request('bug_id')
-        queue_status.active_patch_id = self._int_from_request('patch_id')
-        queue_status.message = self.request.get('status')
+        queue_status.active_bug_id = bug_id
+        queue_status.active_patch_id = patch_id
+        queue_status.message = self.request.get("status")
         results_file = self.request.get("results_file")
         queue_status.results_file = db.Blob(str(results_file))
         queue_status.put()
+        Attachment.dirty(patch_id)
         self.response.out.write(queue_status.key().id())
diff --git a/WebKitTools/QueueStatusServer/model/attachment.py b/WebKitTools/QueueStatusServer/model/attachment.py
new file mode 100644
index 0000000..cc8fbfe
--- /dev/null
+++ b/WebKitTools/QueueStatusServer/model/attachment.py
@@ -0,0 +1,109 @@
+# Copyright (C) 2009 Google Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+# 
+#     * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#     * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import re
+
+from google.appengine.api import memcache
+
+from model.queuestatus import QueueStatus
+
+
+class Attachment(object):
+    @classmethod
+    def dirty(cls, attachment_id):
+        memcache.delete(str(attachment_id), namespace="attachment-summary")
+
+    @classmethod
+    def recent(cls, limit=1):
+        statuses = QueueStatus.all().order("-date")
+        # Notice that we use both a set and a list here to keep the -date ordering.
+        ids = []
+        visited_ids = set()
+        for status in statuses:
+            attachment_id = status.active_patch_id
+            if not attachment_id:
+                continue
+            if attachment_id in visited_ids:
+                continue
+            visited_ids.add(attachment_id)
+            ids.append(attachment_id)
+            if len(visited_ids) >= limit:
+                break
+        return map(cls, ids)
+
+    def __init__(self, attachment_id):
+        self.id = attachment_id
+        self._summary = None
+
+    def summary(self):
+        if self._summary:
+            return self._summary
+        self._summary = memcache.get(str(self.id), namespace="attachment-summary")
+        if self._summary:
+            return self._summary
+        self._summary = self._fetch_summary()
+        memcache.set(str(self.id), self._summary, namespace="attachment-summary")
+        return self._summary
+
+    def _dash_to_underscore(self, dashed_name):
+        regexp = re.compile("-")
+        return regexp.sub("_", dashed_name)
+
+    def _state_from_status(self, status):
+        table = {
+            "Pass" : "pass",
+            "Fail" : "fail",
+        }
+        return table.get(status.message, "none")
+
+    def _fetch_summary(self):
+        summary = { "attachment_id" : self.id }
+
+        first_status = QueueStatus.all().filter('active_patch_id =', self.id).get()
+        if not first_status:
+            # We don't have any record of this attachment.
+            return summary
+        summary["bug_id"] = first_status.active_bug_id
+
+        # FIXME: This should go somewhere else.
+        queues = [
+            "style-queue",
+            "chromium-ews",
+            "qt-ews",
+            "gtk-ews",
+        ]
+
+        for queue in queues:
+            summary[queue] = None
+            status = QueueStatus.all().filter('queue_name =', queue).filter('active_patch_id =', self.id).order('-date').get()
+            if status:
+                summary[self._dash_to_underscore(queue)] = {
+                    "state" : self._state_from_status(status),
+                    "status" : status,
+                }
+        return summary

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list