Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Commit

Permalink
don't post messages on stale PRS
Browse files Browse the repository at this point in the history
fixes #7
  • Loading branch information
ericLemanissier committed Dec 9, 2020
1 parent 98ad9ca commit c18d14c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import requests
import datetime
from datetime import datetime,timedelta,timezone
import os
import aiohttp, asyncio
import dateutil.parser


class Detector:
Expand Down Expand Up @@ -81,7 +82,7 @@ def _make_request(self, method, url, **kwargs):
if int(r.headers["X-RateLimit-Remaining"]) < 10:
print("%s/%s github api call used, remaining %s until %s" % (
r.headers["X-Ratelimit-Used"], r.headers["X-RateLimit-Limit"], r.headers["X-RateLimit-Remaining"],
datetime.datetime.fromtimestamp(int(r.headers["X-Ratelimit-Reset"]))))
datetime.fromtimestamp(int(r.headers["X-Ratelimit-Reset"]))))
return r

def update_issue(self, issue_number):
Expand Down Expand Up @@ -169,6 +170,9 @@ def update_pr_messages(self):
if len(self.libs[lib_name]) <= 1:
continue
for issue_number in self.libs[lib_name]:
if dateutil.parser.isoparse(self.prs[issue_number]["updated_at"]) < datetime.now(timezone.utc) - timedelta(days=15):
print("skipping %s message because PR has not been updated since %s" % (issue_number, self.prs[issue_number]["updated_at"]))
continue
self._post_message_for_lib(issue_number, lib_name)


Expand Down

1 comment on commit c18d14c

@prince-chrismc
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Please sign in to comment.