forked from rDrama/rDrama
1
0
Fork 0

Update user.py

master
Aevann1 2021-07-25 00:34:34 +02:00 committed by GitHub
parent f116469be4
commit 2075e3c322
1 changed files with 7 additions and 3 deletions

View File

@ -177,8 +177,12 @@ class User(Base, Stndrd, Age_times):
@property @property
@lazy @lazy
def dramacoins(self): def dramacoins(self):
posts = sum([x.upvotes + x.downvotes - 1 for x in g.db.query(Submission).options(lazyload('*')).filter_by(author_id=self.id, is_banned=False, deleted_utc=0).all()]) posts = sum([x[0] - 1 for x in
comments = sum([x.upvotes + x.downvotes - 1 for x in g.db.query(Comment).options(lazyload('*')).filter_by(author_id=self.id, is_banned=False, deleted_utc=0).all()]) g.db.query(Submission.score).options(lazyload('*')).filter_by(author_id=self.id, is_banned=False,
deleted_utc=0).all()])
comments = sum([x[0] - 1 for x in
g.db.query(Comment.score).options(lazyload('*')).filter_by(author_id=self.id, is_banned=False,
deleted_utc=0).all()])
return int(posts + comments) return int(posts + comments)
def has_block(self, target): def has_block(self, target):
@ -1012,4 +1016,4 @@ class ViewerRelationship(Base):
return f"{months}mo ago" return f"{months}mo ago"
else: else:
years = int(months / 12) years = int(months / 12)
return f"{years}yr ago" return f"{years}yr ago"