Skip to content

Commit

Permalink
Fix latest_version_modified annotation.
Browse files Browse the repository at this point in the history
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 <tanner.jc@gmail.com>
  • Loading branch information
jctanner committed Oct 24, 2024
1 parent 72da970 commit afb221f
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions pulp_ansible/app/galaxy/v3/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,34 +335,14 @@ 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")
)

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),
Expand Down

0 comments on commit afb221f

Please sign in to comment.