aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/halloween/hacktoberstats.py
diff options
context:
space:
mode:
authorGravatar Hedy Li <[email protected]>2020-10-08 08:36:37 +0000
committerGravatar Hedy Li <[email protected]>2020-10-08 08:36:37 +0000
commit6a1ddc00d553074655613f0972815da3579f50e8 (patch)
treef5de5e74c2afdeaf25858a5bed2fc493aad3b769 /bot/exts/halloween/hacktoberstats.py
parentupdate docstr and comments (diff)
fix topics and label logic
Diffstat (limited to 'bot/exts/halloween/hacktoberstats.py')
-rw-r--r--bot/exts/halloween/hacktoberstats.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/bot/exts/halloween/hacktoberstats.py b/bot/exts/halloween/hacktoberstats.py
index 4f5436af..ab12bf1e 100644
--- a/bot/exts/halloween/hacktoberstats.py
+++ b/bot/exts/halloween/hacktoberstats.py
@@ -299,7 +299,15 @@ class HacktoberStats(commands.Cog):
}
# PRs before oct 3 no need to check for topics
- if itemdict["created_at"] < oct3:
+ # continue the loop if 'hacktoberfest-accepted' is labeled then
+ # there is no need to check for its topics
+ if (itemdict["created_at"] < oct3):
+ outlist.append(itemdict)
+ continue
+ if not ("labels" in item.keys()): # if PR has no labels
+ continue
+ # checking whether "hacktoberfest-accepted" is one of the PR's labels
+ if any(label["name"].casefold() == "hacktoberfest-accepted" for label in item["labels"]):
outlist.append(itemdict)
continue
@@ -313,11 +321,9 @@ class HacktoberStats(commands.Cog):
if not ("names" in jsonresp2.keys()):
logging.error(f"Error fetching topics for {shortname}: {jsonresp2['message']}")
- # PRs after oct 3 must be in repo with 'hacktoberfest' topic
- # unless it has 'hacktoberfest-accepted' label
- if not ("labels" in jsonresp.keys()): # if PR has no labels
- continue
- if ("hacktoberfest" in jsonresp2["names"]) or ("hacktoberfest-accpeted" in jsonresp["labels"]):
+ # PRs after oct 3 that doesn't have 'hacktoberfest-accepted' label
+ # must be in repo with 'hacktoberfest' topic
+ if "hacktoberfest" in jsonresp2["names"]:
outlist.append(itemdict)
return outlist