mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-02-03 00:31:25 -08:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
37d3501136
1 changed files with 10 additions and 11 deletions
|
@ -1190,24 +1190,24 @@ class Post(db.Model):
|
||||||
if vote_direction == 'upvote': # new vote is also up, so remove it
|
if vote_direction == 'upvote': # new vote is also up, so remove it
|
||||||
db.session.delete(existing_vote)
|
db.session.delete(existing_vote)
|
||||||
self.up_votes -= 1
|
self.up_votes -= 1
|
||||||
self.score -= existing_vote.effect
|
self.score -= existing_vote.effect # score - (+1) = score-1
|
||||||
undo = 'Like'
|
undo = 'Like'
|
||||||
else: # new vote is down while previous vote was up, so reverse their previous vote
|
else: # new vote is down while previous vote was up, so reverse their previous vote
|
||||||
existing_vote.effect = -1
|
existing_vote.effect = -1
|
||||||
self.up_votes -= 1
|
self.up_votes -= 1
|
||||||
self.down_votes += 1
|
self.down_votes += 1
|
||||||
self.score -= existing_vote.effect * 2
|
self.score += existing_vote.effect * 2 # score + (-2) = score-2
|
||||||
else: # previous vote was down
|
else: # previous vote was down
|
||||||
if vote_direction == 'downvote': # new vote is also down, so remove it
|
if vote_direction == 'downvote': # new vote is also down, so remove it
|
||||||
db.session.delete(existing_vote)
|
db.session.delete(existing_vote)
|
||||||
self.down_votes -= 1
|
self.down_votes -= 1
|
||||||
self.score += existing_vote.effect
|
self.score -= existing_vote.effect # score - (-1) = score+1
|
||||||
undo = 'Dislike'
|
undo = 'Dislike'
|
||||||
else: # new vote is up while previous vote was down, so reverse their previous vote
|
else: # new vote is up while previous vote was down, so reverse their previous vote
|
||||||
existing_vote.effect = 1
|
existing_vote.effect = 1
|
||||||
self.up_votes += 1
|
self.up_votes += 1
|
||||||
self.down_votes -= 1
|
self.down_votes -= 1
|
||||||
self.score += existing_vote.effect * 2
|
self.score += existing_vote.effect * 2 # score + (+2) = score+2
|
||||||
else:
|
else:
|
||||||
if vote_direction == 'upvote':
|
if vote_direction == 'upvote':
|
||||||
effect = Instance.weight(user.ap_domain)
|
effect = Instance.weight(user.ap_domain)
|
||||||
|
@ -1222,20 +1222,19 @@ class Post(db.Model):
|
||||||
if user.cannot_vote():
|
if user.cannot_vote():
|
||||||
effect = spicy_effect = 0
|
effect = spicy_effect = 0
|
||||||
self.up_votes += 1
|
self.up_votes += 1
|
||||||
self.score += spicy_effect
|
self.score += spicy_effect # score + (+1) = score+1
|
||||||
else:
|
else:
|
||||||
effect = -1.0
|
effect = -1.0
|
||||||
|
spicy_effect = effect
|
||||||
self.down_votes += 1
|
self.down_votes += 1
|
||||||
# Make 'hot' sort more spicy by amplifying the effect of early downvotes
|
# Make 'hot' sort more spicy by amplifying the effect of early downvotes
|
||||||
if self.up_votes + self.down_votes <= 30:
|
if self.up_votes + self.down_votes <= 30:
|
||||||
effect = current_app.config['SPICY_UNDER_30']
|
spicy_effect *= current_app.config['SPICY_UNDER_30']
|
||||||
elif self.up_votes + self.down_votes <= 60:
|
elif self.up_votes + self.down_votes <= 60:
|
||||||
effect = current_app.config['SPICY_UNDER_60']
|
spicy_effect *= current_app.config['SPICY_UNDER_60']
|
||||||
else:
|
|
||||||
effect = -1.0
|
|
||||||
if user.cannot_vote():
|
if user.cannot_vote():
|
||||||
effect = 0
|
effect = spicy_effect = 0
|
||||||
self.score -= effect
|
self.score += spicy_effect # score + (-1) = score-1
|
||||||
vote = PostVote(user_id=user.id, post_id=self.id, author_id=self.author.id,
|
vote = PostVote(user_id=user.id, post_id=self.id, author_id=self.author.id,
|
||||||
effect=effect)
|
effect=effect)
|
||||||
# upvotes do not increase reputation in low quality communities
|
# upvotes do not increase reputation in low quality communities
|
||||||
|
|
Loading…
Add table
Reference in a new issue