|
5 | 5 |
|
6 | 6 | from io import TextIOWrapper |
7 | 7 |
|
8 | | -from datetime import datetime, time, timedelta |
| 8 | +from datetime import datetime, time, timedelta, timezone |
9 | 9 |
|
10 | 10 | from django.core import serializers |
11 | 11 | from django.core.serializers.json import DjangoJSONEncoder |
12 | 12 | from django.db import router, transaction |
13 | | -from django.utils.timezone import now, utc |
| 13 | +from django.utils.timezone import now |
14 | 14 | from django.utils.module_loading import import_string |
15 | 15 |
|
16 | 16 | from celery import current_app |
@@ -290,9 +290,9 @@ def clean_logs(self, type, timestamp, backup_path, stdout, stderr): |
290 | 290 | storage = import_string(settings.BACKUP_STORAGE_CLASS)() |
291 | 291 |
|
292 | 292 | qs = get_log_model_from_logger_name(type).objects.filter(stop__lte=timestamp).order_by('stop') |
293 | | - for step_timestamp in qs.datetimes('start', 'day', tzinfo=utc): |
294 | | - min_timestamp = datetime.combine(step_timestamp, time.min).replace(tzinfo=utc) |
295 | | - max_timestamp = datetime.combine(step_timestamp, time.max).replace(tzinfo=utc) |
| 293 | + for step_timestamp in qs.datetimes('start', 'day', tzinfo=timezone.utc): |
| 294 | + min_timestamp = datetime.combine(step_timestamp, time.min).replace(tzinfo=timezone.utc) |
| 295 | + max_timestamp = datetime.combine(step_timestamp, time.max).replace(tzinfo=timezone.utc) |
296 | 296 | qs_filtered_by_day = qs.filter(stop__range=(min_timestamp, max_timestamp)) |
297 | 297 |
|
298 | 298 | for qs_batch in get_querysets_by_batch(qs_filtered_by_day, settings.CLEAN_LOGS_BACKUP_FILE_BATCH_SIZE): |
|
0 commit comments