Skip to content

Commit

Permalink
fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
jsjiang committed Nov 6, 2024
1 parent cb22ad8 commit b56f6cd
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions ezidapp/management/commands/proc-expunge_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import time
from datetime import datetime
import urllib.error
import urllib.parse
from dateutil.parser import parse
import urllib.request
import urllib.response

Expand Down Expand Up @@ -90,20 +90,23 @@ def run(self):
exit()

if created_from is not None and created_to is not None:
time_range = Q(updateTime__gte=created_from) & Q(updateTime__lte=created_to)
time_range = Q(createTime__gte=created_from) & Q(createTime__lte=created_to)
time_range_str = f"updated between: {created_from_str} and {created_to_str}"
elif created_to is not None:
time_range = Q(updateTime__lte=created_to)
time_range = Q(createTime__lte=created_to)
time_range_str = f"updated before: {created_to_str}"
else:
max_age_ts = int(time.time()) - django.conf.settings.DAEMONS_EXPUNGE_MAX_AGE_SEC
min_age_ts = max_age_ts - django.conf.settings.DAEMONS_EXPUNGE_MAX_AGE_SEC
time_range = Q(updateTime__gte=min_age_ts) & Q(updateTime__lte=max_age_ts)
time_range = Q(createTime__gte=min_age_ts) & Q(createTime__lte=max_age_ts)
time_range_str = f"updated between: {self.seconds_to_date(min_age_ts)} and {self.seconds_to_date(max_age_ts)}"

min_id, max_id = self.get_id_range_by_time(time_range)
filter_by_id = None

print(f"time range: {time_range}")
print(f"min_id: {min_id}, max_id: {max_id}")

while not self.terminated():
# TODO: This is a heavy query which can be optimized with better indexes or
# flags in the DB.
Expand All @@ -123,10 +126,6 @@ def run(self):
if filter_by_id is not None:
combined_filter &= filter_by_id

print(min_age_ts)
print(max_age_ts)
print(min_id)
print(max_id)
print(combined_filter)

qs = (
Expand Down

0 comments on commit b56f6cd

Please sign in to comment.