From afb221fce2422770b941135eb3b0e02f8bbd6d16 Mon Sep 17 00:00:00 2001 From: James Tanner Date: Thu, 24 Oct 2024 18:16:47 -0400 Subject: [PATCH] Fix latest_version_modified annotation. The previous code was using the updated timestamp of the repository version the content was added into. That ended up with in some cases an updated_at timestamp that was older than the created_at timestamp. [noissue] Signed-off-by: James Tanner --- pulp_ansible/app/galaxy/v3/views.py | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/pulp_ansible/app/galaxy/v3/views.py b/pulp_ansible/app/galaxy/v3/views.py index 94bf2638b..6b5fd8a80 100644 --- a/pulp_ansible/app/galaxy/v3/views.py +++ b/pulp_ansible/app/galaxy/v3/views.py @@ -335,24 +335,6 @@ def get_queryset(self): .only("version") ) - latest_version_modified_qs = ( - RepositoryContent.objects.filter( - repository_id=repo_version.repository_id, - version_added__number__lte=repo_version.number, - ) - .select_related("content__ansible_collectionversion") - .select_related("version_added") - .select_related("version_removed") - .filter(content__ansible_collectionversion__collection_id=OuterRef("pk")) - .annotate( - last_updated=Greatest( - "version_added__pulp_created", "version_removed__pulp_created" - ) - ) - .order_by("-last_updated") - .only("last_updated") - ) - download_count_qs = CollectionDownloadCount.objects.filter( name=OuterRef("name"), namespace=OuterRef("namespace") ) @@ -360,9 +342,7 @@ def get_queryset(self): qs = ( Collection.objects.annotate( highest_version=Subquery(latest_cv_version_qs.values("version")[:1]), - latest_version_modified=Subquery( - latest_version_modified_qs.values("last_updated")[:1] - ), + latest_version_modified=Subquery(latest_cv_version_qs.values("pulp_last_updated")[:1]), ) .annotate( deprecated=Exists(deprecated_qs),