remotes/1693045480750635534/spooky-22
Aevann1 2021-07-26 19:00:29 +02:00
parent ccea00cfe6
commit 3e7dcd6690
5 changed files with 7 additions and 13 deletions

View File

@ -122,10 +122,6 @@ class Scores:
@property
#@cache.memoize(timeout=60)
def score_percent(self):
# try:
# return int((self.ups/(self.ups+self.downs))*100)
# except ZeroDivisionError:
# return 0
return 101

View File

@ -164,8 +164,8 @@ def frontlist(v=None, sort="hot", page=1,t="all", ids_only=True, filter_words=''
g.db.add(vote)
try: g.db.flush()
except: g.db.rollback()
post.upvotes = post.ups
post.downvotes = post.downs
post.upvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=1).count()
post.downvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=-1).count()
post.views = post.views + random.randint(7,10)
g.db.add(post)

View File

@ -194,8 +194,8 @@ def post_base36id(pid, anything=None, v=None):
g.db.add(vote)
try: g.db.flush()
except: g.db.rollback()
comment.upvotes = comment.ups
comment.downvotes = comment.downs
comment.upvotes = g.db.query(CommentVote).filter_by(comment_id=comment.id, vote_type=1).count()
comment.downvotes = g.db.query(CommentVote).filter_by(comment_id=comment.id, vote_type=-1).count()
g.db.add(comment)
post._preloaded_comments = [x for x in comments if not (x.author and x.author.shadowbanned) or (v and v.id == x.author_id)]
@ -971,8 +971,6 @@ def submit_post(v):
user = get_account(follow.user_id)
send_notification(2360, user, f"@{v.username} has made a new post: [{title}](https://rdrama.net{new_post.permalink})")
new_post.upvotes = new_post.ups
new_post.downvotes = new_post.downs
g.db.add(new_post)
g.db.commit()

View File

@ -117,8 +117,8 @@ def api_vote_post(post_id, x, v):
g.db.flush()
post.upvotes = g.db.query(Vote).filter_by(comment_id=comment.id, vote_type=1).count()
post.downvotes = g.db.query(Vote).filter_by(comment_id=comment.id, vote_type=-1).count()
post.upvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=1).count()
post.downvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=-1).count()
g.db.add(post)
return "", 204

View File

@ -44,7 +44,7 @@
</form>
{% endif %}
{% endif %}
<p>Score: +{{p.ups}}/-{{p.downs}}</p>
<p>Score: +{{p.upvotes}}/-{{p.downvotes}}</p>
{% endblock %}
{% block content %}