def get_comments_count(post_id): comments_count = get_counter(POST_COMMENTS_COUNT, post_id=post_id) if comments_count is not None: comments_count = Comment.query.filter_by(post_id=post_id).count() return comments_count
def inc_comments_count(post_id): comments_count = get_counter(POST_COMMENTS_COUNT, post_id=post_id) if comments_count is None: CommentService.set_comments_count(post_id) else: inc_counter(POST_COMMENTS_COUNT, post_id=post_id)