remotes/1693045480750635534/spooky-22
Aevann1 2021-07-24 16:49:03 +02:00
parent 397b0ae4d9
commit f86236a27e
1 changed files with 4 additions and 36 deletions

View File

@ -177,12 +177,8 @@ class User(Base, Stndrd, Age_times):
@property
@lazy
def dramacoins(self):
posts = sum([x[0] - 1 for x in
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()])
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()])
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()])
return int(posts + comments)
def has_block(self, target):
@ -781,8 +777,8 @@ class User(Base, Stndrd, Age_times):
# Takes care of all functions needed for account reinstatement.
self.is_banned = None
self.unban_utc = None
self.is_banned = 0
self.unban_utc = 0
g.db.add(self)
@ -882,34 +878,6 @@ class User(Base, Stndrd, Age_times):
return [x[0] for x in comments.offset(25 * (page - 1)).limit(26).all()]
def guild_rep(self, guild, recent=0):
posts = g.db.query(Submission.score).filter_by(
is_banned=False,
original_board_id=guild.id)
if recent:
cutoff = int(time.time()) - 60 * 60 * 24 * recent
posts = posts.filter(Submission.created_utc > cutoff)
posts = posts.all()
post_rep = sum([x[0] for x in posts]) - len(list(sum([x[0] for x in posts])))
comments = g.db.query(Comment.score).filter_by(
is_banned=False,
original_board_id=guild.id)
if recent:
cutoff = int(time.time()) - 60 * 60 * 24 * recent
comments = comments.filter(Comment.created_utc > cutoff)
comments = comments.all()
comment_rep = sum([x[0] for x in comments]) - len(list(sum([x[0] for x in comments])))
return int(post_rep + comment_rep)
@property
def has_premium(self):