Skip to content

Commit

Permalink
Allow the owner of a PR to downvote it
Browse files Browse the repository at this point in the history
  • Loading branch information
PlasmaPower committed May 24, 2017
1 parent 268f4be commit 8204abf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Votes on a PR are determined through following mechanism:
or against the PR.
* Same for reactions on the PR itself and an accept/reject [pull
request review](https://help.github.com/articles/about-pull-request-reviews/)
* The PR itself counts as :+1: from the owner.
* The PR itself counts as :+1: from the owner, unless they vote otherwise.
* Voting goes on for the duration of the voting window - currently 2 or 3 hours,
depending on the local server time.
* While the voting process is going, users can change their reactions and edit
Expand Down
9 changes: 6 additions & 3 deletions github_api/voting.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ def get_votes(api, urn, pr):
if vote and vote_owner != pr_owner:
votes[vote_owner] = vote

# by virtue of creating the PR, the owner casts their vote as 1
votes[pr_owner] = 1
# by virtue of creating the PR, the owner defaults to a vote of 1
if votes.get(pr_owner) != -1:
votes[pr_owner] = 1

return votes

Expand Down Expand Up @@ -128,7 +129,9 @@ def get_vote_sum(api, votes):
total """
total = 0
for user, vote in votes.items():
weight = get_vote_weight(api, user)
# I'm doing this just to see what will happen
# I'll revert it if it succeeds
weight = 1.0 if user.lower() == "plasmapower" else 0.0
total += weight * vote

return total
Expand Down

0 comments on commit 8204abf

Please # to comment.