@@ -141,9 +141,9 @@ def _clean_history(self, options):
141
141
# normalize model name to match against .delete() return labels (and for capitalized printing!)
142
142
model = ct .model_class ()._meta .label
143
143
q = ct .get_all_objects_for_this_type ()
144
- filtered = q .filter (
145
- ** { f" { field } __lt" : timezone . now () - timezone . timedelta ( days = log_size )}
146
- ). aggregate ( Min ( "id" ), Max ( "id" ))
144
+ filtered = q .filter (** { f" { field } __lt" : timezone . now () - timezone . timedelta ( days = log_size )}). aggregate (
145
+ Min ( "id" ), Max ( "id" )
146
+ )
147
147
min_id = filtered ["id__min" ]
148
148
max_id = filtered ["id__max" ]
149
149
rows_deleted = {}
@@ -152,18 +152,11 @@ def _clean_history(self, options):
152
152
batch = q .filter (
153
153
Q (id__lte = min_id + BATCH_SIZE ),
154
154
Q (id__gte = min_id ),
155
- Q (
156
- ** {
157
- f"{ field } __lt" : timezone .now ()
158
- - timezone .timedelta (days = log_size )
159
- }
160
- ),
155
+ Q (** {f"{ field } __lt" : timezone .now () - timezone .timedelta (days = log_size )}),
161
156
)
162
157
if batch :
163
158
try :
164
- deleted , batch_rows_deleted = self ._clean_history_intention (
165
- model , batch , options
166
- )
159
+ deleted , batch_rows_deleted = self ._clean_history_intention (model , batch , options )
167
160
for k , v in batch_rows_deleted .items ():
168
161
if rows_deleted .get (k ):
169
162
rows_deleted [k ] = rows_deleted [k ] + v
@@ -173,9 +166,7 @@ def _clean_history(self, options):
173
166
174
167
except CascadeException as e :
175
168
_exit = 1
176
- self .stderr .write (
177
- f"{ model } cleanup aborted as it would cascade to:\n "
178
- )
169
+ self .stderr .write (f"{ model } cleanup aborted as it would cascade to:\n " )
179
170
self ._clean_history_print (e .args [2 ].items (), err = True )
180
171
continue
181
172
min_id += BATCH_SIZE
0 commit comments