Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the owner of a PR to downvote it #138

Merged
merged 1 commit into from
May 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link

@loic-sharma loic-sharma May 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Um? 😟

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sneaky!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dictator of chaosbot, @PlasmaPower ! 👏

total += weight * vote

return total
Expand Down