From 8204abf7a2d24621b81ed26aee6ec5a11ece307f Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Tue, 23 May 2017 21:02:48 -0600 Subject: [PATCH] Allow the owner of a PR to downvote it --- README.md | 2 +- github_api/voting.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3a5f7d9f..4f2c492b 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/github_api/voting.py b/github_api/voting.py index a847f95d..f45835f0 100644 --- a/github_api/voting.py +++ b/github_api/voting.py @@ -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 @@ -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