fddf
This commit is contained in:
parent
8661942068
commit
41bbdf12fd
3 changed files with 48 additions and 0 deletions
|
@ -347,6 +347,18 @@ class User(Base, Stndrd, Age_times):
|
|||
|
||||
return sorted(list(awards.values()), key=lambda x: x['kind'], reverse=True)
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def received_awards_num(self):
|
||||
|
||||
posts_idlist = g.db.query(Submission.id).filter_by(author_id=self.id).subquery()
|
||||
comments_idlist = g.db.query(Comment.id).filter_by(author_id=self.id).subquery()
|
||||
|
||||
post_awards = g.db.query(AwardRelationship).filter(AwardRelationship.submission_id.in_(posts_idlist)).count()
|
||||
comment_awards = g.db.query(AwardRelationship).filter(AwardRelationship.comment_id.in_(comments_idlist)).count()
|
||||
|
||||
return post_awards + comment_awards
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def post_notifications_count(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue