Skip to content

DB: do not fetch data and others when deleting rows #10446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions readthedocs/analytics/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ def delete_old_page_counts():
"""
retention_days = settings.RTD_ANALYTICS_DEFAULT_RETENTION_DAYS
days_ago = timezone.now().date() - timezone.timedelta(days=retention_days)
return PageView.objects.filter(
date__lt=days_ago,
date__gt=days_ago - timezone.timedelta(days=90),
).delete()
return (
PageView.objects.filter(
date__lt=days_ago,
date__gt=days_ago - timezone.timedelta(days=90),
)
.only("id")
.delete()
)
12 changes: 8 additions & 4 deletions readthedocs/telemetry/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ def delete_old_build_data():
"""
retention_days = settings.RTD_TELEMETRY_DATA_RETENTION_DAYS
days_ago = timezone.now().date() - timezone.timedelta(days=retention_days)
return BuildData.objects.filter(
created__lt=days_ago,
created__gt=days_ago - timezone.timedelta(days=90),
).delete()
return (
BuildData.objects.filter(
created__lt=days_ago,
created__gt=days_ago - timezone.timedelta(days=90),
)
.only("id")
.delete()
)