Skip to content

Commit

Permalink
Revert "Field updated_at from Galaxy v3 Collections endpoint using la…
Browse files Browse the repository at this point in the history
…test instead of highest version"

This reverts commit c43b89c.

https://pulp.plan.io/issues/7990
closes #7990
  • Loading branch information
fao89 committed Dec 11, 2020
1 parent 443c901 commit b34aa25
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 116 deletions.
1 change: 1 addition & 0 deletions CHANGES/7990.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Field ``updated_at`` from Galaxy v3 Collections endpoint using highest version
6 changes: 2 additions & 4 deletions pulp_ansible/app/galaxy/v3/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ def get_created_at(self, obj):

def get_updated_at(self, obj):
"""Get the timestamp of the highest version CollectionVersion's created timestamp."""
if obj.repo_version_added_at and obj.repo_version_removed_at:
return max(obj.repo_version_added_at, obj.repo_version_removed_at)

return obj.repo_version_added_at or obj.repo_version_removed_at
collection = self.context["highest_versions"][obj.pk]
return collection.pulp_created

@extend_schema_field(OpenApiTypes.OBJECT)
def get_highest_version(self, obj):
Expand Down
23 changes: 4 additions & 19 deletions pulp_ansible/app/galaxy/v3/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from gettext import gettext as _
import semantic_version

from django.db.models import Exists, OuterRef, Subquery, Max
from django.db.models import Exists, OuterRef
from django.shortcuts import get_object_or_404
from django.utils.datastructures import MultiValueDictKeyError
from django.utils.dateparse import parse_datetime
Expand All @@ -17,7 +17,7 @@
from rest_framework import viewsets

from pulpcore.plugin.exceptions import DigestValidationError
from pulpcore.plugin.models import PulpTemporaryFile, Content, ContentArtifact, RepositoryVersion
from pulpcore.plugin.models import PulpTemporaryFile, Content, ContentArtifact
from pulpcore.plugin.serializers import AsyncOperationResponseSerializer

from pulp_ansible.app.galaxy.v3.exceptions import ExceptionHandlerMixin
Expand Down Expand Up @@ -153,23 +153,8 @@ def get_queryset(self):
deprecated_query = AnsibleCollectionDeprecated.objects.filter(
collection=OuterRef("pk"), repository_version=repo_version
)
added_repo_version_query = RepositoryVersion.objects.filter(
repository=repo_version.repository,
complete=True,
added_memberships__content__in=OuterRef("versions__pk"),
).values("pulp_last_updated")
removed_repo_version_query = RepositoryVersion.objects.filter(
repository=repo_version.repository,
complete=True,
removed_memberships__content__in=OuterRef("versions__pk"),
).values("pulp_last_updated")

collections_qs_annotated = Collection.objects.annotate(
repo_version_added_at=Max(Subquery(added_repo_version_query)),
repo_version_removed_at=Max(Subquery(removed_repo_version_query)),
deprecated=Exists(deprecated_query),
)
collections = collections_qs_annotated.filter(versions__in=repo_version.content).distinct()
collections = Collection.objects.filter(versions__in=repo_version.content).distinct()
collections = collections.annotate(deprecated=Exists(deprecated_query))

versions_qs = CollectionVersion.objects.filter(pk__in=repo_version.content).values_list(
"collection_id",
Expand Down

This file was deleted.

0 comments on commit b34aa25

Please sign in to comment.