This commit is contained in:
Aevann1 2021-09-01 21:03:05 +02:00
parent 8661942068
commit 41bbdf12fd
3 changed files with 48 additions and 0 deletions

View file

@ -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):