You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by tv...@apache.org on 2013/06/20 22:33:40 UTC

git commit: [#6379] Add BlogPost indexes

Updated Branches:
  refs/heads/tv/6379 [created] 13461dfef


[#6379] Add BlogPost indexes

Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>


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

Branch: refs/heads/tv/6379
Commit: 13461dfef7177b5607beccf3d1b436afdbb20652
Parents: 1bae8fa
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Thu Jun 20 19:59:08 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Thu Jun 20 19:59:08 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/macro.py        | 5 ++++-
 ForgeBlog/forgeblog/model/blog.py | 5 +++++
 2 files changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/13461dfe/Allura/allura/lib/macro.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/macro.py b/Allura/allura/lib/macro.py
index 1e6c353..27c0d35 100644
--- a/Allura/allura/lib/macro.py
+++ b/Allura/allura/lib/macro.py
@@ -131,7 +131,10 @@ def project_blog_posts(max_number=5, sort='timestamp', summary=False, mount_poin
     for conf in c.project.app_configs:
         if conf.tool_name.lower() == 'blog' and (mount_point is None or conf.options.mount_point==mount_point):
             app_config_ids.append(conf._id)
-    posts = BM.BlogPost.query.find({'state':'published','app_config_id':{'$in':app_config_ids}})
+    posts = BM.BlogPost.query.find({
+        'app_config_id': {'$in': app_config_ids},
+        'state':'published',
+    })
     posts = posts.sort(sort, pymongo.DESCENDING).limit(int(max_number)).all()
     output = ((dict(
                 href=post.url(),

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/13461dfe/ForgeBlog/forgeblog/model/blog.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/model/blog.py b/ForgeBlog/forgeblog/model/blog.py
index d5ec233..c629f5c 100644
--- a/ForgeBlog/forgeblog/model/blog.py
+++ b/ForgeBlog/forgeblog/model/blog.py
@@ -103,6 +103,11 @@ class BlogPost(M.VersionedArtifact, ActivityObject):
         name='blog_post'
         history_class = BlogPostSnapshot
         unique_indexes = [ ('app_config_id', 'slug') ]
+        indexes = [
+            ('app_config_id', 'state', 'timestamp'),
+            ('neighborhood_id', 'state', 'timestamp'),
+        ]
+
     type_s = 'Blog Post'
 
     title = FieldProperty(str, if_missing='Untitled')