def get_posts_count(tags_filter=[], category_filter=""): # Use the sharded counter for the unfiltered number of posts count if not tags_filter and not category_filter: return counter.get_count("Posts_Count") # Use the counter of the tag if len(tags_filter) == 1 and not category_filter: tag = Tag.get_tag(tags_filter[0]) if tag: return tag.counter else: return 0 # Use the counter of the category if category_filter and not tags_filter: category = Category.get_category(category_filter) if category: return category.counter else: return 0 posts = Post.all(keys_only=True) if category_filter: posts.filter("category", category_filter) for tag in tags_filter: if tag: posts.filter("tags", tag) return posts.count(limit=None)
def GET(self): questions_printed = web.utils.commify(dbcounter.get_count()) return render.index(questions_printed)