From 3211ec5ede11bbeb97354e0423843363677c84b7 Mon Sep 17 00:00:00 2001 From: emma2207 Date: Thu, 1 May 2025 10:02:44 -0600 Subject: [PATCH 1/2] fix issues.totalCount problem --- upkeep.py | 22 ++++++++++++++-------- uptime.txt | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/upkeep.py b/upkeep.py index c1dee3d..fce25dd 100644 --- a/upkeep.py +++ b/upkeep.py @@ -10,14 +10,14 @@ import github -class PennHolidays(holidays.UnitedStates): +# class PennHolidays(holidays.UnitedStates): - def _populate(self, year): - super()._populate(year) +# def _populate(self, year): +# super()._populate(year) - # See https://github.com/greenelab/scrum/issues/114 - for day in range(26, 32): - self[datetime.date(year, 12, day)] = 'Special Winter Vacation' +# # See https://github.com/greenelab/scrum/issues/114 +# for day in range(26, 32): +# self[datetime.date(year, 12, day)] = 'Special Winter Vacation' holiday_names = { @@ -31,7 +31,7 @@ def _populate(self, year): 'Special Winter Vacation', } -penn_holidays = PennHolidays() +# penn_holidays = PennHolidays() def get_today() -> datetime.date: @@ -174,7 +174,13 @@ def get_upcoming_workdays(workdays_ahead: int = 2) -> typing.Iterator[datetime.d # to help ensure the most recent existing e-scrum issue is included even when other # non e-scrum issues exist issues = repo.get_issues(state='all', sort='number', direction='desc') - issues = issues[:min(10 + args.workdays_ahead, issues.totalCount)] + if issues.totalCount > 0: + issues = issues[:min(10 + args.workdays_ahead, issues.totalCount)] + else: + try: + issues = issues[:(10 + args.workdays_ahead)] + except: + pass date_issue_pairs = [(issue_title_to_date(issue.title), issue) for issue in issues] # Filter issues that are not scrum entries filtered_date_issue_pairs = [(date, issue) for date, issue in date_issue_pairs if date] diff --git a/uptime.txt b/uptime.txt index cdd2c4b..df5a654 100644 --- a/uptime.txt +++ b/uptime.txt @@ -1 +1 @@ -It has been 884 days since I last had to tinker with the scrum bot. +It has been 0 days since I last had to tinker with the scrum bot. From d923f1235469772c826f02dd76df46fee0d48d6e Mon Sep 17 00:00:00 2001 From: emma2207 Date: Thu, 1 May 2025 10:12:06 -0600 Subject: [PATCH 2/2] comments --- upkeep.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/upkeep.py b/upkeep.py index fce25dd..15468f0 100644 --- a/upkeep.py +++ b/upkeep.py @@ -10,14 +10,14 @@ import github -# class PennHolidays(holidays.UnitedStates): +class PennHolidays(holidays.UnitedStates): -# def _populate(self, year): -# super()._populate(year) + def _populate(self, year): + super()._populate(year) -# # See https://github.com/greenelab/scrum/issues/114 -# for day in range(26, 32): -# self[datetime.date(year, 12, day)] = 'Special Winter Vacation' + # See https://github.com/greenelab/scrum/issues/114 + for day in range(26, 32): + self[datetime.date(year, 12, day)] = 'Special Winter Vacation' holiday_names = { @@ -31,7 +31,7 @@ 'Special Winter Vacation', } -# penn_holidays = PennHolidays() +penn_holidays = PennHolidays() def get_today() -> datetime.date: @@ -174,11 +174,14 @@ def get_upcoming_workdays(workdays_ahead: int = 2) -> typing.Iterator[datetime.d # to help ensure the most recent existing e-scrum issue is included even when other # non e-scrum issues exist issues = repo.get_issues(state='all', sort='number', direction='desc') + # If totalCount is working properly if issues.totalCount > 0: issues = issues[:min(10 + args.workdays_ahead, issues.totalCount)] else: + # Try reducing the number of issues try: issues = issues[:(10 + args.workdays_ahead)] + # But if that's not possible, just continue except: pass date_issue_pairs = [(issue_title_to_date(issue.title), issue) for issue in issues]