-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Delete pageviews in the same way as imported files #12410
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
base: main
Are you sure you want to change the base?
Conversation
This is similar to #12386, but trying to do a simpler version first.
readthedocs/projects/tasks/utils.py
Outdated
if version: | ||
version.imported_files.all().delete() | ||
version.page_views.all().delete() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also called when a version is deactivated, do we want to remove pageviews in that case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure, tbh. I guess it's pretty aggressive, and might cause people to lose data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may want to call these on Project.delete and Version.delete only
if version: | ||
version.imported_files.all().delete() | ||
else: | ||
project.imported_files.all().delete() | ||
project.page_views.all().delete() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't necessary called when a project is deleted, it's also called from the admin. I'd put this under the delete method only (most of this data can be recovered, but pageview can't).
This is similar to #12386,
but trying to do a simpler version first.
https://docs.djangoproject.com/en/5.2/topics/db/queries/#deleting-objects