Skip to content

Commit

Permalink
Merge pull request #1 from MINIMAN10000/MINIMAN10000
Browse files Browse the repository at this point in the history
Removed all references to since
  • Loading branch information
MINIMAN10000 authored May 24, 2017
2 parents cc0e7fe + 2c23904 commit c912331
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
6 changes: 2 additions & 4 deletions github_api/comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
import settings


def get_reactions_for_comment(api, urn, comment_id, since):
def get_reactions_for_comment(api, urn, comment_id):
path = "/repos/{urn}/issues/comments/{comment}/reactions"\
.format(urn=urn, comment=comment_id)
params = {"per_page": settings.DEFAULT_PAGINATION}
reactions = api("get", path, params=params)
for reaction in reactions:
created = arrow.get(reaction["created_at"])
if created > since:
yield reaction
yield reaction

def leave_reject_comment(api, urn, pr):
body = """
Expand Down
9 changes: 3 additions & 6 deletions github_api/prs.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,10 @@ def get_pr_last_updated(pr_data):
return arrow.get(dt)


def get_pr_comments(api, urn, pr_num, since):
def get_pr_comments(api, urn, pr_num):
""" yield all comments on a pr, weirdly excluding the initial pr comment
itself (the one the owner makes) """
params = {
"since": misc.dt_to_github_dt(since),
"per_page": settings.DEFAULT_PAGINATION
}
path = "/repos/{urn}/issues/{pr}/comments".format(urn=urn, pr=pr_num)
Expand Down Expand Up @@ -156,12 +155,10 @@ def get_open_prs(api, urn):
return data


def get_reactions_for_pr(api, urn, pr, since):
def get_reactions_for_pr(api, urn, pr):
path = "/repos/{urn}/issues/{pr}/reactions".format(urn=urn, pr=pr)
params = {"per_page": settings.DEFAULT_PAGINATION}
reactions = api("get", path, params=params)
for reaction in reactions:
created = arrow.get(reaction["created_at"])
if created > since:
yield reaction
yield reaction

17 changes: 8 additions & 9 deletions github_api/voting.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ def get_votes(api, urn, pr):
votes = {}
pr_owner = pr["user"]["login"]
pr_num = pr["number"]
since = prs.get_pr_last_updated(pr)

# get all the comment-and-reaction-based votes
for voter, vote in get_pr_comment_votes_all(api, urn, pr_num, since):
for voter, vote in get_pr_comment_votes_all(api, urn, pr_num):
votes[voter] = vote

# get all the pr-review-based votes
Expand All @@ -38,10 +37,10 @@ def get_votes(api, urn, pr):
return votes


def get_pr_comment_votes_all(api, urn, pr_num, since):
def get_pr_comment_votes_all(api, urn, pr_num):
""" yields votes via comments and votes via reactions on comments for a
given pr """
for comment in prs.get_pr_comments(api, urn, pr_num, since):
for comment in prs.get_pr_comments(api, urn, pr_num):
comment_owner = comment["user"]["login"]

vote = parse_comment_for_vote(comment["body"])
Expand All @@ -68,27 +67,27 @@ def get_pr_comment_votes_all(api, urn, pr_num, since):
# we consider the pr itself to be the "first comment." in the web ui, it
# looks like a comment, complete with reactions, so let's treat it like a
# comment
reaction_votes = get_pr_reaction_votes(api, urn, pr_num, since)
reaction_votes = get_pr_reaction_votes(api, urn, pr_num)
for reaction_owner, vote in reaction_votes:
yield reaction_owner, vote



def get_pr_reaction_votes(api, urn, pr_num, since):
def get_pr_reaction_votes(api, urn, pr_num):
""" yields reaction votes to a pr-comment. very similar to getting
reactions from comments on the pr """
reactions = prs.get_reactions_for_pr(api, urn, pr_num, since)
reactions = prs.get_reactions_for_pr(api, urn, pr_num)
for reaction in reactions:
reaction_owner = reaction["user"]["login"]
vote = parse_reaction_for_vote(reaction["content"])
if vote:
yield reaction_owner, vote


def get_comment_reaction_votes(api, urn, comment_id, since):
def get_comment_reaction_votes(api, urn, comment_id):
""" yields votes via reactions on comments on a pr. don't use this
directly, it is called by get_pr_comment_votes_all """
reactions = comments.get_reactions_for_comment(api, urn, comment_id, since)
reactions = comments.get_reactions_for_comment(api, urn, comment_id)
for reaction in reactions:
reaction_owner = reaction["user"]["login"]
vote = parse_reaction_for_vote(reaction["content"])
Expand Down

0 comments on commit c912331

Please sign in to comment.