django-cms / djangocms-versioning

General purpose versioning package for Django CMS 4 and above.
Other
33 stars 29 forks source link

feat: Huge performance improvement for admin_manager #318

Closed fsbraun closed 1 year ago

fsbraun commented 1 year ago

Description

The admin_manager of a versioned model provided access to current_content_iterator which allowed to "filter" out all current versions of the model: Either draft or published (if there is no draft). This API had the drawback that the result was not a queryset but an iterator (since the grouping was done in python).

This method is now replaced by current_content() which is a filter that returns a queryset that only contains the current verison of the objects. Not only is it more convenient to have a qs returned, the number of database hits reduces from O(n) with n being the number of objects to 1.

current_content_iterator is kept to ensure compatibility with django CMS v4.1.0rc1

Related resources

Checklist

codecov[bot] commented 1 year ago

Codecov Report

Merging #318 (28ee6a6) into master (906d501) will increase coverage by 0.00%. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #318   +/-   ##
=======================================
  Coverage   89.91%   89.91%           
=======================================
  Files          68       68           
  Lines        2250     2251    +1     
  Branches      301      300    -1     
=======================================
+ Hits         2023     2024    +1     
  Misses        172      172           
  Partials       55       55           
Impacted Files Coverage Δ
djangocms_versioning/managers.py 82.69% <100.00%> (+0.33%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.