aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar kosayoda <[email protected]>2019-10-23 20:46:51 +0800
committerGravatar kosayoda <[email protected]>2019-10-23 20:46:51 +0800
commitbba22f492f94702857526a068900612d85167928 (patch)
tree6739b5310acf6e334a561a91dce88b7a18cd232d
parentIgnore Draft PRs in .hackstats (diff)
Filter draft PRs in query url instead
-rw-r--r--bot/seasons/halloween/hacktoberstats.py15
1 files changed, 4 insertions, 11 deletions
diff --git a/bot/seasons/halloween/hacktoberstats.py b/bot/seasons/halloween/hacktoberstats.py
index ef2c880c..40c680db 100644
--- a/bot/seasons/halloween/hacktoberstats.py
+++ b/bot/seasons/halloween/hacktoberstats.py
@@ -225,6 +225,7 @@ class HacktoberStats(commands.Cog):
not_label = "invalid"
action_type = "pr"
is_query = f"public+author:{github_username}"
+ not_query = "draft"
date_range = f"{CURRENT_YEAR}-10-01T00:00:00%2B14:00..{CURRENT_YEAR}-10-31T23:59:59-11:00"
per_page = "300"
query_url = (
@@ -232,20 +233,15 @@ class HacktoberStats(commands.Cog):
f"-label:{not_label}"
f"+type:{action_type}"
f"+is:{is_query}"
+ f"+-is:{not_query}"
f"+created:{date_range}"
f"&per_page={per_page}"
)
- # Use custom media type in Accept header to get `draft` field in API returns
- # https://developer.github.com/changes/2019-02-14-draft-pull-requests/
- headers = {
- "user-agent": "Discord Python Hacktoberbot",
- "Accept": "application/vnd.github.shadow-cat-preview+json"
- }
-
async with aiohttp.ClientSession() as session:
- async with session.get(query_url, headers=headers) as resp:
+ async with session.get(query_url) as resp:
jsonresp = await resp.json()
+
if "message" in jsonresp.keys():
# One of the parameters is invalid, short circuit for now
api_message = jsonresp["errors"][0]["message"]
@@ -260,8 +256,6 @@ class HacktoberStats(commands.Cog):
logging.info(f"Found {len(jsonresp['items'])} Hacktoberfest PRs for GitHub user: '{github_username}'")
outlist = []
for item in jsonresp["items"]:
- if item["draft"] is True: # Draft PRs don't count
- continue
shortname = HacktoberStats._get_shortname(item["repository_url"])
itemdict = {
"repo_url": f"https://www.github.com/{shortname}",
@@ -271,7 +265,6 @@ class HacktoberStats(commands.Cog):
),
}
outlist.append(itemdict)
- logging.info(f"Found {len(outlist)} valid Hacktoberfest PRs for GitHub user: '{github_username}'")
return outlist
@staticmethod