3333def case_close_reminder (db_session : Session , project : Project ):
3434 """Sends a reminder to the case assignee to close out their case."""
3535 cases = get_all_by_status (
36- db_session = db_session ,
37- project_id = project .id ,
38- statuses = [CaseStatus .triage ]
36+ db_session = db_session , project_id = project .id , statuses = [CaseStatus .triage ]
3937 )
4038
4139 for case in cases :
@@ -61,12 +59,7 @@ def case_triage_reminder(db_session: Session, project: Project):
6159 db_session .query (Case )
6260 .filter (Case .project_id == project .id )
6361 .filter (Case .status != CaseStatus .closed )
64- .filter (
65- or_ (
66- Case .title == "Security Event Triage" ,
67- Case .status == CaseStatus .new
68- )
69- )
62+ .filter (or_ (Case .title == "Security Event Triage" , Case .status == CaseStatus .new ))
7063 .all ()
7164 )
7265
@@ -90,12 +83,13 @@ def case_stable_reminder(db_session: Session, project: Project):
9083
9184 for case in cases :
9285 try :
93- span = datetime .utcnow () - case .stable_at
94- q , r = divmod (span .days , 7 )
95- if q >= 1 and date .today ().isoweekday () == 1 :
96- # we only send the reminder for cases that have been stable
97- # longer than a week and only on Mondays
98- send_case_close_reminder (case , db_session )
86+ if case .stable_at :
87+ span = datetime .utcnow () - case .stable_at
88+ q , r = divmod (span .days , 7 )
89+ if q >= 1 and date .today ().isoweekday () == 1 :
90+ # we only send the reminder for cases that have been stable
91+ # longer than a week and only on Mondays
92+ send_case_close_reminder (case , db_session )
9993 except Exception as e :
10094 # if one fails we don't want all to fail
10195 log .exception (e )
0 commit comments