incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [2/3] git commit: [#6431] ticket:430 Upgrade to ming 0.4.x to avoid extraneous count() queries
Date Wed, 25 Sep 2013 21:57:45 GMT
[#6431] ticket:430 Upgrade to ming 0.4.x to avoid extraneous count() queries


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/dfd8b5e9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/dfd8b5e9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/dfd8b5e9

Branch: refs/heads/db/6431
Commit: dfd8b5e9e99641d254d4e898d0749b46538e3cb2
Parents: a17ae4a
Author: Yuriy Arhipov <yuriyarhipovua@yandex.ru>
Authored: Sun Sep 22 13:21:07 2013 +0400
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed Sep 25 20:53:25 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py                         | 2 +-
 Allura/allura/controllers/project.py                      | 6 +++---
 Allura/allura/controllers/trovecategories.py              | 2 +-
 Allura/allura/ext/admin/templates/project_tools.html      | 2 +-
 Allura/allura/model/artifact.py                           | 2 +-
 Allura/allura/templates/widgets/moderate_posts.html       | 2 +-
 ForgeTracker/forgetracker/templates/tracker/ticket.html   | 2 +-
 ForgeTracker/forgetracker/tests/unit/test_ticket_model.py | 4 ++--
 requirements-common.txt                                   | 2 +-
 9 files changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/dfd8b5e9/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index fa00208..50b550f 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -511,7 +511,7 @@ class UserSkillsController(BaseController):
             selected_skill = selected_skill,
             parents = parents,
             menu = menu,
-            add_details_fields=(len(l)==0))
+            add_details_fields=(l.count() == 0))
 
     @expose()
     @require_post()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/dfd8b5e9/Allura/allura/controllers/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index e2c7ee8..a1a952c 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -537,7 +537,7 @@ class NeighborhoodAdminController(object):
         awards = M.Award.query.find(dict(created_by_neighborhood_id=self.neighborhood._id)).all()
         awards_count = len(awards)
         grants = M.AwardGrant.query.find(dict(granted_by_neighborhood_id=self.neighborhood._id))
-        grants_count = len(grants)
+        grants_count = grants.count()
         c.project_select = W.project_select(self.neighborhood.url() + '_admin/project_search')
         return dict(
             awards=awards,
@@ -756,7 +756,7 @@ class NeighborhoodAwardsController(object):
     def index(self, **kw):
         require_access(self.neighborhood, 'admin')
         awards = M.Award.query.find(dict(created_by_neighborhood_id=self.neighborhood._id))
-        count = len(awards)
+        count = awards.count()
         return dict(awards=awards or [], count=count)
 
     @expose('jinja:allura:templates/award_not_found.html')
@@ -767,7 +767,7 @@ class NeighborhoodAwardsController(object):
     def grants(self, **kw):
         require_access(self.neighborhood, 'admin')
         grants = M.AwardGrant.query.find(dict(granted_by_neighborhood_id=self.neighborhood._id))
-        count = len(grants)
+        count = grants.count()
         return dict(grants=grants or [], count=count)
 
     @expose()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/dfd8b5e9/Allura/allura/controllers/trovecategories.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/trovecategories.py b/Allura/allura/controllers/trovecategories.py
index 79cb88c..86d4738 100644
--- a/Allura/allura/controllers/trovecategories.py
+++ b/Allura/allura/controllers/trovecategories.py
@@ -59,7 +59,7 @@ class TroveCategoryController(BaseController):
                hierarchy = [temp_cat] + hierarchy
                temp_cat = temp_cat.parent_category
         else:
-            l = M.TroveCategory.query.find(dict(trove_parent_id=0))
+            l = M.TroveCategory.query.find(dict(trove_parent_id=0)).all()
             selected_cat = None
             hierarchy = []
         return dict(

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/dfd8b5e9/Allura/allura/ext/admin/templates/project_tools.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/project_tools.html b/Allura/allura/ext/admin/templates/project_tools.html
index 36f98f5..78fb8f1 100644
--- a/Allura/allura/ext/admin/templates/project_tools.html
+++ b/Allura/allura/ext/admin/templates/project_tools.html
@@ -44,7 +44,7 @@
     </span>
   </div>
   <form method="post" action="update_mounts" id="install_form" style="display:none">
-    <input type="hidden" name="new.ordinal" value="{{installable_tools|length + c.project.direct_subprojects|length}}"/>
+    <input type="hidden" name="new.ordinal" value="{{installable_tools|length + c.project.direct_subprojects.count()}}"/>
     <input type="hidden" name="new.ep_name" class="new_ep_name">
     <label class="grid-13">Label</label>
     <div class="grid-13"><input type="text" name="new.mount_label" class="new_mount_label"></div>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/dfd8b5e9/Allura/allura/model/artifact.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/artifact.py b/Allura/allura/model/artifact.py
index 2804a17..8753f1e 100644
--- a/Allura/allura/model/artifact.py
+++ b/Allura/allura/model/artifact.py
@@ -540,7 +540,7 @@ class VersionedArtifact(Artifact):
     @property
     def last_updated(self):
         history = self.history()
-        if len(history):
+        if history.count():
             return self.history().first().timestamp
         else:
             return self.mod_date

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/dfd8b5e9/Allura/allura/templates/widgets/moderate_posts.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/moderate_posts.html b/Allura/allura/templates/widgets/moderate_posts.html
index 25294a3..e243b9a 100644
--- a/Allura/allura/templates/widgets/moderate_posts.html
+++ b/Allura/allura/templates/widgets/moderate_posts.html
@@ -53,7 +53,7 @@
           <td>{{author.display_name}} ({{author.username}})</td>
           <td>{{post.thread.subject or '(no subject)'}}</td>
           <td>{{h.text.truncate(post.text,200)}}</td>
-          <td>{{post.attachments|length}}</td>
+          <td>{{post.attachments.count()}}</td>
           <td>
           {% if c.app.config.tool_name.lower() != 'discussion' %}
             <a href="{{post.thread.artifact.url()}}">[{{post.thread.artifact.shorthand_id()}}]</a>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/dfd8b5e9/ForgeTracker/forgetracker/templates/tracker/ticket.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker/ticket.html b/ForgeTracker/forgetracker/templates/tracker/ticket.html
index f6288bb..f780736 100644
--- a/ForgeTracker/forgetracker/templates/tracker/ticket.html
+++ b/ForgeTracker/forgetracker/templates/tracker/ticket.html
@@ -144,7 +144,7 @@
 <div id="ticket_content">
   {{g.markdown.convert(ticket.description)|safe}}
   {% if ticket.attachments %}
-    <strong class="grid-18">{{ticket.attachments.__len__()}} Attachments</strong>
+    <strong class="grid-18">{{ticket.attachments.count()}} Attachments</strong>
     <div class="clear">
     {% for att in ticket.attachments %}
         <div class="attachment_thumb">

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/dfd8b5e9/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py b/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
index 7f7fdd7..620abcf 100644
--- a/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
+++ b/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
@@ -270,12 +270,12 @@ class TestTicketModel(TrackerTestWithModel):
             ticket = Ticket.new()
             ticket.summary = 'test ticket'
             ticket.description = 'test description'
-        assert_equal(len(ticket.attachments), 0)
+        assert_equal(ticket.attachments.count(), 0)
         f = urllib2.urlopen('file://%s' % __file__)
         TicketAttachment.save_attachment('test_ticket_model.py', ResettableStream(f),
                                             artifact_id=ticket._id)
         ThreadLocalORMSession.flush_all()
-        assert_equal(len(ticket.attachments), 1)
+        assert_equal(ticket.attachments.count(), 1)
         assert_equal(ticket.attachments.first().filename, 'test_ticket_model.py')
 
     def test_json_parents(self):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/dfd8b5e9/requirements-common.txt
----------------------------------------------------------------------
diff --git a/requirements-common.txt b/requirements-common.txt
index 42bdadb..51c7636 100644
--- a/requirements-common.txt
+++ b/requirements-common.txt
@@ -21,7 +21,7 @@ httplib2==0.7.4
 iso8601==0.1.4
 Jinja2==2.6
 Markdown==2.2.0
-Ming==0.3.10
+Ming==0.4.1
 oauth2==1.5.170
 # tg2 dep PasteDeploy must specified before TurboGears2, to avoid a version/allow-hosts problem
 Paste==1.7.5.1


Mime
View raw message