Skip to content

Commit

Permalink
Fix: Linear in stead of quadratic complexity in current_content que…
Browse files Browse the repository at this point in the history
…ryset method.
  • Loading branch information
fsbraun committed Jul 14, 2024
1 parent 778254f commit 7f239f5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions djangocms_versioning/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ def current_content(self, **kwargs):
versions or published versions (in that order). This optimized query assumes that
draft versions always have a higher pk than any other version type. This is true as long as
no other version type can be converted to draft without creating a new version."""
qs = self.filter(versions__state__in=(constants.DRAFT, constants.PUBLISHED), **kwargs)
qs = self.filter(versions__state__in=(constants.DRAFT, constants.PUBLISHED))
pk_filter = qs.values(*self._group_by_key)\
.annotate(vers_pk=models.Max("versions__pk"))\
.values_list("vers_pk", flat=True)
return qs.filter(versions__pk__in=pk_filter)
.values("vers_pk")
return self.filter(versions__pk__in=pk_filter, **kwargs)

def latest_content(self, **kwargs):
"""Returns the "latest" content object which is in this order
Expand Down

0 comments on commit 7f239f5

Please sign in to comment.