incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [37/50] git commit: [#3154] avoid doing an extra count() query or storing all items in memory
Date Wed, 21 Aug 2013 15:27:19 GMT
[#3154] avoid doing an extra count() query or storing all items in memory


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

Branch: refs/heads/db/3154b
Commit: dd4700db10eb5d6687e5e643534e695f3682adbf
Parents: 8c96f3a
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Tue Aug 6 15:37:20 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed Aug 21 15:25:58 2013 +0000

----------------------------------------------------------------------
 ForgeBlog/forgeblog/main.py                   | 5 ++---
 ForgeDiscussion/forgediscussion/forum_main.py | 7 +++----
 ForgeTracker/forgetracker/tracker_main.py     | 7 +++----
 ForgeWiki/forgewiki/wiki_main.py              | 7 +++----
 4 files changed, 11 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/dd4700db/ForgeBlog/forgeblog/main.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index e6da34f..6f344cb 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -193,11 +193,10 @@ class ForgeBlogApp(Application):
     def bulk_export(self, f):
         f.write('{"posts": [')
         posts = BM.BlogPost.query.find(dict(app_config_id=self.config._id)).sort('timestamp',
pymongo.DESCENDING)
-        count = len(posts)
         for i, post in enumerate(posts):
-            json.dump(post, f, cls=jsonify.GenericJSON, indent=2)
-            if i < (count - 1):
+            if i > 0:
                 f.write(',')
+            json.dump(post, f, cls=jsonify.GenericJSON, indent=2)
         f.write(']}')
 
 class RootController(BaseController, FeedController):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/dd4700db/ForgeDiscussion/forgediscussion/forum_main.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/forum_main.py b/ForgeDiscussion/forgediscussion/forum_main.py
index bf1835d..a91508d 100644
--- a/ForgeDiscussion/forgediscussion/forum_main.py
+++ b/ForgeDiscussion/forgediscussion/forum_main.py
@@ -219,12 +219,11 @@ class ForgeDiscussionApp(Application):
 
     def bulk_export(self, f):
         f.write('{"forums": [')
-        forums = DM.Forum.query.find(dict(app_config_id=self.config._id)).sort('mod_date',
pymongo.DESCENDING).all()
-        count = len(forums)
+        forums = DM.Forum.query.find(dict(app_config_id=self.config._id)).sort('mod_date',
pymongo.DESCENDING)
         for i, forum in enumerate(forums):
-            json.dump(forum, f, cls=jsonify.GenericJSON, indent=2)
-            if i < (count - 1):
+            if i > 0:
                 f.write(',')
+            json.dump(forum, f, cls=jsonify.GenericJSON, indent=2)
         f.write(']}')
 
 class ForumAdminController(DefaultAdminController):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/dd4700db/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index f76a843..d09710d 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -412,12 +412,11 @@ class ForgeTrackerApp(Application):
         f.write('{"tickets": [')
         tickets = TM.Ticket.query.find(dict(
             app_config_id=self.config._id,
-            deleted=False)).all()
-        count = len(tickets)
+            deleted=False))
         for i, ticket in enumerate(tickets):
-            json.dump(ticket, f, cls=jsonify.GenericJSON, indent=2)
-            if i < (count - 1):
+            if i > 0:
                 f.write(',')
+            json.dump(ticket, f, cls=jsonify.GenericJSON, indent=2)
         f.write('],\n"tracker_config":')
         json.dump(self.config, f, cls=jsonify.GenericJSON, indent=2)
         f.write(',\n"milestones":')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/dd4700db/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index f0b85a7..5fecbb2 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -291,12 +291,11 @@ The wiki uses [Markdown](%s) syntax.
         f.write('{"pages": [')
         pages = WM.Page.query.find(dict(
             app_config_id=self.config._id,
-            deleted=False)).all()
-        count = len(pages)
+            deleted=False))
         for i, page in enumerate(pages):
-            json.dump(page, f, cls=jsonify.GenericJSON, indent=2)
-            if i < (count - 1):
+            if i > 0:
                 f.write(',')
+            json.dump(page, f, cls=jsonify.GenericJSON, indent=2)
         f.write(']}')
 
 


Mime
View raw message