本文整理汇总了Python中app.models.Comment.count_by_post方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.count_by_post方法的具体用法?Python Comment.count_by_post怎么用?Python Comment.count_by_post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.models.Comment
的用法示例。
在下文中一共展示了Comment.count_by_post方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _post_info
# 需要导入模块: from app.models import Comment [as 别名]
# 或者: from app.models.Comment import count_by_post [as 别名]
def _post_info(post):
info = post.to_dict()
favorites = Favorite.count_by_post(post.id)
up_votes = PostUpVote.count_by_post(post.id)
down_votes = PostDownVote.count_by_post(post.id)
latest_comment = Comment.latest_by_post(post.id)
comment_count = Comment.count_by_post(post.id)
if latest_comment:
latest_comment_user = User.get(latest_comment.author_id).username
latest_comment_date = latest_comment.date
else:
latest_comment_user = None
latest_comment_date = None
info.update({
'up_votes': up_votes,
'down_votes': down_votes,
'favorites': favorites,
'latest_comment_user': latest_comment_user,
'latest_comment_date': latest_comment_date,
'comment_count': comment_count,
})
return info