-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Pre-populate version.content
cache when getting version object
#446
base: master
Are you sure you want to change the base?
Conversation
Reviewer's Guide by SourceryThis pull request pre-populates the version's field cache with the content object when retrieving a version, avoiding database hits when accessing the version's content. Sequence diagram for optimized version content retrievalsequenceDiagram
participant Client
participant Version
participant Database
Client->>Version: get_for_content(content_object)
Version->>Database: Query version by content_object.pk
Database-->>Version: Return version
Note over Version: Cache content_object in version._state.fields_cache
Note over Version: Cache version in content_object._version_cache
Version-->>Client: Return version with cached content
Class diagram showing Version model caching changesclassDiagram
class Version {
-_state: ModelState
+get_for_content(content_object)
+convert_to_proxy()
+content: ContentObject
}
class ModelState {
-fields_cache: dict
}
class ContentObject {
-_version_cache: Version
}
Version *-- ModelState
Version -- ContentObject
note for Version "Added caching of content object
in fields_cache to avoid DB hits"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @fsbraun - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #446 +/- ##
==========================================
- Coverage 90.63% 89.77% -0.87%
==========================================
Files 72 72
Lines 2702 2718 +16
Branches 314 318 +4
==========================================
- Hits 2449 2440 -9
- Misses 179 201 +22
- Partials 74 77 +3 ☔ View full report in Codecov by Sentry. |
…jangocms-versioning into feat/efficiency-improvement
Description
The checks framework triggers database hits when accessing a
version.content
object. This PR adds the content object to the version's field cache to avoid these unnecessary database hits.The failing test against django-cms@develop-4 fails due to an import order issue for the core's
cms.toolbar.toolbar.CMSToolbar
. This prevents the core to use versioning's prefetching and is fixed by django-cms/django-cms#8120Related resources
Checklist
master
Slack to find a “pr review buddy” who is going to review my pull request.
Summary by Sourcery
Enhancements: