Skip to content

Commit d275493

Browse files
authored
Merge pull request #11 from NilashishC/master
Return only those issues that were created within the specified timedelta
2 parents 26979c5 + 7e77095 commit d275493

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

triager/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def main():
5656
help="save logging information to a file",
5757
)
5858
group.add_argument(
59-
"--log", action="store_true", help="display logging data on console",
59+
"--log", action="store_true", help="display logging data on console"
6060
)
6161

6262
parser.add_argument(
@@ -70,7 +70,7 @@ def main():
7070
)
7171

7272
group.add_argument(
73-
"--version", action="store_true", help="show version number",
73+
"--version", action="store_true", help="show version number"
7474
)
7575

7676
args = parser.parse_args()

triager/config.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,13 @@ def __init__(self, cfg):
5050
"password": config["triager"]["password"],
5151
}
5252
except KeyError as exc:
53-
logging.error(f"triager config malformed, key {exc!s} not found")
53+
logging.error(
54+
f"triager config malformed, key {exc!s} not found"
55+
)
5456
except TypeError:
55-
logging.error("triager config malformed, should be a dictionary")
57+
logging.error(
58+
"triager config malformed, should be a dictionary"
59+
)
5660
else:
5761
logging.debug("triager not found in config, will not send email")
5862

triager/triager.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import logging
2+
from datetime import datetime
23

34
import requests
45

5-
66
REQUEST_FMT = "https://api.github.com/repos/{0}/{1}/issues"
77

88

@@ -34,15 +34,19 @@ def triage(config):
3434
return {}
3535

3636
for item in resp.json():
37-
issues[repo_name].append(
38-
{
39-
"url": item["html_url"],
40-
"title": item["title"],
41-
"type": "Pull Request"
42-
if item.get("pull_request")
43-
else "Issue",
44-
}
37+
created_at = datetime.strptime(
38+
item["created_at"], "%Y-%m-%dT%H:%M:%SZ"
4539
)
40+
if created_at >= config.last_triage_date:
41+
issues[repo_name].append(
42+
{
43+
"url": item["html_url"],
44+
"title": item["title"],
45+
"type": "Pull Request"
46+
if item.get("pull_request")
47+
else "Issue",
48+
}
49+
)
4650

4751
logging.info("triage successfully completed")
4852
return issues

0 commit comments

Comments
 (0)