Skip to content

Commit

Permalink
Fix issue with wrong until in GitHub search
Browse files Browse the repository at this point in the history
  • Loading branch information
Felixoid committed Oct 10, 2024
1 parent bb23ea5 commit 010a0c5
Showing 1 changed file with 34 additions and 8 deletions.
42 changes: 34 additions & 8 deletions did/plugins/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
# Identifier padding
PADDING = 3

# Number of issues to be fetched per page
# Number of GH items to be fetched per page
PER_PAGE = 100


Expand Down Expand Up @@ -78,6 +78,11 @@ def condition(key: str, names: str) -> list[str]:
condition("org", org) +
condition("repo", repo))

@staticmethod
def until(until):
"""Issue #362: until for GH should have - delta(day=1)"""
return until - 1

def search(self, query):
""" Perform GitHub query """
result = []
Expand Down Expand Up @@ -182,8 +187,11 @@ class IssuesCreated(Stats):

def fetch(self):
log.info("Searching for issues created by {0}".format(self.user))
user = self.user.login
since = self.options.since
until = GitHub.until(self.options.until)
query = "search/issues?q=author:{0}+created:{1}..{2}".format(
self.user.login, self.options.since, self.options.until)
user, since, until)
query += "+type:issue"
self.stats = [
Issue(issue, self.parent) for issue in self.parent.github.search(query)]
Expand All @@ -194,8 +202,11 @@ class IssuesClosed(Stats):

def fetch(self):
log.info("Searching for issues closed by {0}".format(self.user))
user = self.user.login
since = self.options.since
until = GitHub.until(self.options.until)
query = "search/issues?q=assignee:{0}+closed:{1}..{2}".format(
self.user.login, self.options.since, self.options.until)
user, since, until)
query += "+type:issue"
self.stats = [
Issue(issue, self.parent) for issue in self.parent.github.search(query)]
Expand All @@ -206,8 +217,11 @@ class IssueCommented(Stats):

def fetch(self):
log.info("Searching for issues commented on by {0}".format(self.user))
user = self.user.login
since = self.options.since
until = GitHub.until(self.options.until)
query = "search/issues?q=commenter:{0}+updated:{1}..{2}".format(
self.user.login, self.options.since, self.options.until)
user, since, until)
query += "+type:issue"
self.stats = [
Issue(issue, self.parent) for issue in self.parent.github.search(query)]
Expand All @@ -219,8 +233,11 @@ class PullRequestsCreated(Stats):
def fetch(self):
log.info("Searching for pull requests created by {0}".format(
self.user))
user = self.user.login
since = self.options.since
until = GitHub.until(self.options.until)
query = "search/issues?q=author:{0}+created:{1}..{2}".format(
self.user.login, self.options.since, self.options.until)
user, since, until)
query += "+type:pr"
self.stats = [
Issue(issue, self.parent) for issue in self.parent.github.search(query)]
Expand All @@ -232,8 +249,11 @@ class PullRequestsCommented(Stats):
def fetch(self):
log.info("Searching for pull requests commented on by {0}".format(
self.user))
user = self.user.login
since = self.options.since
until = GitHub.until(self.options.until)
query = "search/issues?q=commenter:{0}+updated:{1}..{2}".format(
self.user.login, self.options.since, self.options.until)
user, since, until)
query += "+type:pr"
self.stats = [
Issue(issue, self.parent) for issue in self.parent.github.search(query)]
Expand All @@ -245,8 +265,11 @@ class PullRequestsClosed(Stats):
def fetch(self):
log.info("Searching for pull requests closed by {0}".format(
self.user))
user = self.user.login
since = self.options.since
until = GitHub.until(self.options.until)
query = "search/issues?q=assignee:{0}+closed:{1}..{2}".format(
self.user.login, self.options.since, self.options.until)
user, since, until)
query += "+type:pr"
self.stats = [
Issue(issue, self.parent) for issue in self.parent.github.search(query)]
Expand All @@ -258,8 +281,11 @@ class PullRequestsReviewed(Stats):
def fetch(self):
log.info("Searching for pull requests reviewed by {0}".format(
self.user))
user = self.user.login
since = self.options.since
until = GitHub.until(self.options.until)
query = "search/issues?q=reviewed-by:{0}+-author:{0}+closed:{1}..{2}".format(
self.user.login, self.options.since, self.options.until)
user, since, until)
query += "+type:pr"
self.stats = [
Issue(issue, self.parent) for issue in self.parent.github.search(query)]
Expand Down

0 comments on commit 010a0c5

Please sign in to comment.