Skip to content

Commit

Permalink
BUG: Fixes /prs command.
Browse files Browse the repository at this point in the history
  • Loading branch information
khalford committed Sep 24, 2024
1 parent 8bc1c52 commit bce02d3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea/
1 change: 1 addition & 0 deletions cloud-chatops/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ schedule
slack-bolt
aiohttp
requests
python-dateutil
pytest
pytest-cov
pylint
Expand Down
8 changes: 6 additions & 2 deletions cloud-chatops/src/features/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from typing import List
from datetime import datetime, timedelta
from dateutil import parser as datetime_parser
from slack_sdk import WebClient
from slack_sdk.errors import SlackApiError
from enum_states import PRsFoundState
Expand Down Expand Up @@ -64,7 +65,9 @@ def post_thread_messages(self, prs: List[PrData], post_all: bool) -> None:
prs_posted = PRsFoundState.NONE_FOUND
for pr in prs:
checked_pr = self.check_pr(pr)
prs_posted = self.filter_thread_message(checked_pr, post_all)
post_status = self.filter_thread_message(checked_pr, post_all)
if post_status == PRsFoundState.PRS_FOUND:
prs_posted = PRsFoundState.PRS_FOUND

if prs_posted == PRsFoundState.NONE_FOUND:
self.send_no_prs()
Expand Down Expand Up @@ -110,7 +113,8 @@ def check_pr(self, info: PrData) -> PrData:
info.user = DEFAULT_AUTHOR
else:
info.user = self._github_to_slack_username(info.user)
opened_date = datetime.fromisoformat(info.created_at).replace(tzinfo=None)
print(info.created_at)
opened_date = datetime_parser.parse(info.created_at).replace(tzinfo=None)
datetime_now = datetime.now().replace(tzinfo=None)
time_cutoff = datetime_now - timedelta(days=30 * 6)
if opened_date < time_cutoff:
Expand Down

0 comments on commit bce02d3

Please sign in to comment.