Changeset 70016 in webkit
- Timestamp:
- Oct 18, 2010 7:13:19 PM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 8 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r70014 r70016 1 2010-10-18 Eric Seidel <eric@webkit.org> 2 3 Reviewed by Adam Barth. 4 5 Deploy Queue class in more places throughout QueueStatusServer 6 https://bugs.webkit.org/show_bug.cgi?id=47855 7 8 I also caught two typos from the previous change. Unfortunately 9 I don't yet know how to unittest request handlers yet. 10 11 * QueueStatusServer/handlers/dashboard.py: 12 * QueueStatusServer/handlers/statusbubble.py: 13 * QueueStatusServer/handlers/updateworkitems.py: 14 * QueueStatusServer/model/activeworkitems.py: 15 * QueueStatusServer/model/attachment.py: 16 * QueueStatusServer/model/queuepropertymixin.py: Added. 17 * QueueStatusServer/model/queuepropertymixin_unittest.py: Added. 18 * QueueStatusServer/model/queuestatus.py: 19 * QueueStatusServer/model/workitems.py: 20 1 21 2010-10-18 Adam Barth <abarth@webkit.org> 2 22 -
trunk/WebKitTools/QueueStatusServer/handlers/dashboard.py
r70006 r70016 42 42 43 43 def _build_bubble(self, attachment, queue): 44 queue_status = attachment.status_for_queue(queue .name())44 queue_status = attachment.status_for_queue(queue) 45 45 bubble = { 46 46 "status_class": attachment.state_from_queue_status(queue_status) if queue_status else "none", -
trunk/WebKitTools/QueueStatusServer/handlers/statusbubble.py
r70006 r70016 41 41 42 42 def _build_bubble(self, queue, attachment): 43 queue_status = attachment.status_for_queue(queue .name())43 queue_status = attachment.status_for_queue(queue) 44 44 bubble = { 45 45 "name": queue.short_name().lowercase(), 46 46 "attachment_id": attachment.id, 47 "queue_position": attachment.position_in_queue(queue .name()),47 "queue_position": attachment.position_in_queue(queue), 48 48 "state": attachment.state_from_queue_status(queue_status) if queue_status else "none", 49 49 "status": queue_status, -
trunk/WebKitTools/QueueStatusServer/handlers/updateworkitems.py
r70006 r70016 41 41 self.response.out.write(template.render("templates/updateworkitems.html", None)) 42 42 43 def _work_items_for_queue(self, queue_name): 44 queue = Queue.queue_for_name(queue_name) 45 if queue: 46 self.response.out.write("\"%s\" is not in queues %s" % (queue_name, Queue.all())) 47 return None 48 work_items = WorkItems.all().filter("queue_name =", queue_name).get() 43 def _work_items_for_queue(self, queue): 44 work_items = WorkItems.all().filter("queue_name =", queue.name()).get() 49 45 if not work_items: 50 46 work_items = WorkItems() 51 work_items.queue _name = queue_name47 work_items.queue = queue 52 48 return work_items 53 49 … … 59 55 def _work_items_from_request(self): 60 56 queue_name = self.request.get("queue_name") 61 work_items = self._work_items_for_queue(queue_name) 57 queue = Queue.queue_for_name(queue_name) 58 if not queue: 59 self.response.out.write("\"%s\" is not in queues %s" % (queue_name, Queue.all())) 60 return None 61 62 work_items = self._work_items_for_queue(queue) 62 63 if not work_items: 63 64 return None -
trunk/WebKitTools/QueueStatusServer/model/activeworkitems.py
r68491 r70016 32 32 import time 33 33 34 from model.queuepropertymixin import QueuePropertyMixin 34 35 35 class ActiveWorkItems(db.Model): 36 37 class ActiveWorkItems(db.Model, QueuePropertyMixin): 36 38 queue_name = db.StringProperty() 37 39 item_ids = db.ListProperty(int) -
trunk/WebKitTools/QueueStatusServer/model/attachment.py
r70006 r70016 88 88 return None 89 89 90 def position_in_queue(self, queue _name):91 return self._queue_positions().get(queue _name)90 def position_in_queue(self, queue): 91 return self._queue_positions().get(queue.name()) 92 92 93 def status_for_queue(self, queue_name): 94 underscore_queue_name = Queue(queue_name).name_with_underscores() 93 def status_for_queue(self, queue): 95 94 # summary() is a horrible API and should be killed. 96 queue_summary = self.summary().get( underscore_queue_name)95 queue_summary = self.summary().get(queue.name_with_underscores()) 97 96 if not queue_summary: 98 97 return None … … 110 109 111 110 def _calculate_queue_positions(self): 112 queue_positions = {} 113 for work_items in WorkItems.all().fetch(limit=len(queues)): 114 queue_name = str(work_items.queue_name) 115 try: 116 position = work_items.item_ids.index(self.id) 117 # Display 1-based indecies to the user. 118 queue_positions[queue_name] = position + 1 119 except ValueError, e: 120 queue_positions[queue_name] = None 121 return queue_positions 111 all_work_items = WorkItems.all().fetch(limit=len(Queues.all())) 112 return dict([(items.queue.name(), items.display_position_for_attachment(self.id)) for items in all_work_items]) 122 113 123 114 # FIXME: This is controller/view code and does not belong in a model. … … 131 122 summary["bug_id"] = first_status.active_bug_id 132 123 133 for queue in queues:134 summary[queue ] = None135 status = QueueStatus.all().filter('queue_name =', queue ).filter('active_patch_id =', self.id).order('-date').get()124 for queue in Queues.all(): 125 summary[queue.name_with_underscores()] = None 126 status = QueueStatus.all().filter('queue_name =', queue.name()).filter('active_patch_id =', self.id).order('-date').get() 136 127 if status: 137 queue_name = Queue(queue_name).name_with_underscores()138 128 # summary() is a horrible API and should be killed. 139 summary[queue _name] = {129 summary[queue.name_with_underscores()] = { 140 130 "state": self.state_from_queue_status(status), 141 131 "status": status, -
trunk/WebKitTools/QueueStatusServer/model/queuepropertymixin.py
r70015 r70016 27 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 29 from google.appengine.ext import db29 from model.queues import Queue 30 30 31 31 32 class WorkItems(db.Model): 33 queue_name = db.StringProperty() 34 item_ids = db.ListProperty(int) 35 date = db.DateTimeProperty(auto_now_add=True) 32 class QueuePropertyMixin(object): 33 def _queue_getter(self): 34 return Queue.queue_from_name(self.queue_name) 35 36 def _queue_setter(self, queue): 37 self.queue_name = queue.name() if queue else None 38 39 queue = property(_queue_getter, _queue_setter) -
trunk/WebKitTools/QueueStatusServer/model/queuepropertymixin_unittest.py
r70015 r70016 1 # Copyright (C) 2010 Google Inc. All rights reserved.1 # Copyright (C) 2010 Google, Inc. All rights reserved. 2 2 # 3 3 # Redistribution and use in source and binary forms, with or without … … 5 5 # met: 6 6 # 7 # 7 # * Redistributions of source code must retain the above copyright 8 8 # notice, this list of conditions and the following disclaimer. 9 # 9 # * Redistributions in binary form must reproduce the above 10 10 # copyright notice, this list of conditions and the following disclaimer 11 11 # in the documentation and/or other materials provided with the 12 12 # distribution. 13 # * Neither the name of Google Inc. nor the names of its13 # * Neither the name of Research in Motion Ltd. nor the names of its 14 14 # contributors may be used to endorse or promote products derived from 15 15 # this software without specific prior written permission. … … 27 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 29 from google.appengine.ext import db 29 import unittest 30 31 from model.queuepropertymixin import QueuePropertyMixin 32 from model.queues import Queue 30 33 31 34 32 class WorkItems(db.Model): 33 queue_name = db.StringProperty() 34 item_ids = db.ListProperty(int) 35 date = db.DateTimeProperty(auto_now_add=True) 35 class ObjectWithQueueName(QueuePropertyMixin): 36 def __init__(self): 37 self.queue_name = None 38 39 40 class QueuePropertyMixinTest(unittest.TestCase): 41 def test_queue_property(self): 42 test_object = ObjectWithQueueName() 43 mac_ews = Queue("mac-ews") 44 test_object.queue = mac_ews 45 self.assertEquals(test_object.queue_name, "mac-ews") 46 test_object.queue = None 47 self.assertEquals(test_object.queue_name, None) 48 49 50 if __name__ == '__main__': 51 unittest.main() -
trunk/WebKitTools/QueueStatusServer/model/queuestatus.py
r68673 r70016 28 28 29 29 from google.appengine.ext import db 30 from model.queuepropertymixin import QueuePropertyMixin 30 31 31 class QueueStatus(db.Model): 32 33 class QueueStatus(db.Model, QueuePropertyMixin): 32 34 author = db.UserProperty() 33 35 queue_name = db.StringProperty() -
trunk/WebKitTools/QueueStatusServer/model/workitems.py
r59534 r70016 29 29 from google.appengine.ext import db 30 30 31 from model.queuepropertymixin import QueuePropertyMixin 31 32 32 class WorkItems(db.Model): 33 34 class WorkItems(db.Model, QueuePropertyMixin): 33 35 queue_name = db.StringProperty() 34 36 item_ids = db.ListProperty(int) 35 37 date = db.DateTimeProperty(auto_now_add=True) 38 39 def display_position_for_attachment(self, attachment_id): 40 """Returns a 1-based index corresponding to the position 41 of the attachment_id in the queue. If the attachment is 42 not in this queue, this returns None""" 43 if attachment_id in attachment_id: 44 return self.item_ids.index(attachment_id) + 1 45 return None
Note: See TracChangeset
for help on using the changeset viewer.