Skip to content

Commit

Permalink
merging PR #138: Allow the owner of a PR to downvote it
Browse files Browse the repository at this point in the history
#138: Allow the owner of a PR to downvote it

Description:
Redo of #77 with merge conflicts fixed.

:ok_woman: PR passed with a vote of 17 for and 14 against, with a
weighted total of 4.6 and a threshold of 1.0.

Vote record:
@aaronduino: 1
@DasSkelett: -1
@ECrownofFire: -1
@Goofybud16: 1
@INightmare: 1
@Kalabasa: -1
@LasaleFamine: -1
@MarHoff: -1
@PlasmaPower: 1
@Redmega: 1
@akilegaspi: 1
@amoffat: -1
@arunoda: 1
@bperson: -1
@crispmark: 1
@demiters: -1
@dylanaraps: 1
@eukaryote31: 1
@hfern: 1
@hongaar: -1
@ike709: 1
@jackcutting: -1
@jblz: -1
@loic-sharma: -1
@matthewc-mps-aust: -1
@pangeacake: 1
@pchauncey: 1
@serhalp: 1
@swaggy: -1
@syrusakbary: 1
@tarunbatra: 1
  • Loading branch information
chaosbot authored May 24, 2017
2 parents 1efccfd + 8204abf commit 76e6862
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 76e6862

Please sign in to comment.