Use a materialized Extension.latest_version field instead of a dynamic property #152

Merged
Oleg-Komarov merged 15 commits from latest-version-field into main 2024-05-27 17:58:56 +02:00
Owner

Original reason for this change is #128: we need an efficient way to query tags of a latest_version.

We could potentially avoid converting this property to a field if we had a proper search engine, but we would still need to define the same explicit triggers for reindexing - i.e. recompute the latest_version change.

This PR also takes a stab at simplifying data flow, but more work is needed to improve the management of is_listed and status fields.

Original reason for this change is #128: we need an efficient way to query tags of a latest_version. We could potentially avoid converting this property to a field if we had a proper search engine, but we would still need to define the same explicit triggers for reindexing - i.e. recompute the latest_version change. This PR also takes a stab at simplifying data flow, but more work is needed to improve the management of `is_listed` and `status` fields.
Oleg-Komarov added 9 commits 2024-05-27 16:50:52 +02:00
Oleg-Komarov added 2 commits 2024-05-27 17:01:16 +02:00
Anna Sirota reviewed 2024-05-27 17:36:44 +02:00
@ -0,0 +29,4 @@
latest_version = version
break
extension.latest_version = latest_version
extension.save(update_fields={'latest_version'})
Owner

Extension.objects.bulk_update(.., fields={'latest_version'})

`Extension.objects.bulk_update(.., fields={'latest_version'})`
Oleg-Komarov marked this conversation as resolved
@ -415,1 +409,4 @@
@transaction.atomic
def update_latest_version(self, skip_version=None):
versions = self.versions.all().order_by('-date_created')
Owner

select_related missing for .file

`select_related` missing for `.file`
Oleg-Komarov marked this conversation as resolved
@ -416,0 +429,4 @@
and self.versions.filter(file__status=File.STATUSES.APPROVED).count() > 0
)
# this method is called from post_save signal, this early return above should prevent a loop
Owner

"below"?

"below"?
Oleg-Komarov marked this conversation as resolved
@ -222,3 +222,3 @@
_get_all_form_errors(response),
)
self.assertFalse("TODO: It should also list previews as required")
# self.assertFalse("TODO: It should also list previews as required")
Owner

should a separate commit, out of scope

should a separate commit, out of scope
Oleg-Komarov marked this conversation as resolved
Oleg-Komarov added 2 commits 2024-05-27 17:48:29 +02:00
Oleg-Komarov added 1 commit 2024-05-27 17:52:56 +02:00
Oleg-Komarov added 1 commit 2024-05-27 17:57:13 +02:00
Anna Sirota approved these changes 2024-05-27 17:58:04 +02:00
Oleg-Komarov merged commit db67d94507 into main 2024-05-27 17:58:56 +02:00
Oleg-Komarov deleted branch latest-version-field 2024-05-27 17:58:56 +02:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: infrastructure/extensions-website#152
No description provided.