@@ -32,7 +32,7 @@ def archive_old_issues():
3232 archive_in = project .archive_in
3333
3434 # Get all the issues whose updated_at in less that the archive_in month
35- issues = Issue .objects .filter (
35+ issues = Issue .issue_objects .filter (
3636 Q (
3737 project = project_id ,
3838 archived_at__isnull = True ,
@@ -64,21 +64,22 @@ def archive_old_issues():
6464 issues_to_update .append (issue )
6565
6666 # Bulk Update the issues and log the activity
67- updated_issues = Issue .objects .bulk_update (
68- issues_to_update , ["archived_at" ], batch_size = 100
69- )
70- [
71- issue_activity .delay (
72- type = "issue.activity.updated" ,
73- requested_data = json .dumps ({"archived_at" : str (issue .archived_at )}),
74- actor_id = str (project .created_by_id ),
75- issue_id = issue .id ,
76- project_id = project_id ,
77- current_instance = None ,
78- subscriber = False ,
67+ if issues_to_update :
68+ updated_issues = Issue .objects .bulk_update (
69+ issues_to_update , ["archived_at" ], batch_size = 100
7970 )
80- for issue in updated_issues
81- ]
71+ [
72+ issue_activity .delay (
73+ type = "issue.activity.updated" ,
74+ requested_data = json .dumps ({"archived_at" : str (issue .archived_at )}),
75+ actor_id = str (project .created_by_id ),
76+ issue_id = issue .id ,
77+ project_id = project_id ,
78+ current_instance = None ,
79+ subscriber = False ,
80+ )
81+ for issue in updated_issues
82+ ]
8283 return
8384 except Exception as e :
8485 if settings .DEBUG :
@@ -99,7 +100,7 @@ def close_old_issues():
99100 close_in = project .close_in
100101
101102 # Get all the issues whose updated_at in less that the close_in month
102- issues = Issue .objects .filter (
103+ issues = Issue .issue_objects .filter (
103104 Q (
104105 project = project_id ,
105106 archived_at__isnull = True ,
@@ -136,19 +137,20 @@ def close_old_issues():
136137 issues_to_update .append (issue )
137138
138139 # Bulk Update the issues and log the activity
139- updated_issues = Issue .objects .bulk_update (issues_to_update , ["state" ], batch_size = 100 )
140- [
141- issue_activity .delay (
142- type = "issue.activity.updated" ,
143- requested_data = json .dumps ({"closed_to" : str (issue .state_id )}),
144- actor_id = str (project .created_by_id ),
145- issue_id = issue .id ,
146- project_id = project_id ,
147- current_instance = None ,
148- subscriber = False ,
149- )
150- for issue in updated_issues
151- ]
140+ if issues_to_update :
141+ updated_issues = Issue .objects .bulk_update (issues_to_update , ["state" ], batch_size = 100 )
142+ [
143+ issue_activity .delay (
144+ type = "issue.activity.updated" ,
145+ requested_data = json .dumps ({"closed_to" : str (issue .state_id )}),
146+ actor_id = str (project .created_by_id ),
147+ issue_id = issue .id ,
148+ project_id = project_id ,
149+ current_instance = None ,
150+ subscriber = False ,
151+ )
152+ for issue in updated_issues
153+ ]
152154 return
153155 except Exception as e :
154156 if settings .DEBUG :
0 commit comments