~ | | This introduces Profile.get_starred_review_requests_count() and
|
~ | | Profile.get_starred_review_groups_count() , which return the number of
|
~ | | corresponding items starred by the user, either on a specific Local Site
|
| ~ | This introduces new functions to Profile for querying starred review
|
| ~ | request and group information in a way that leverages a cache. The
|
| ~ | following functions have been added: |
- | | or on the global site. |
| |
|
~ | | Most users don't star items, and likely don't star them very often. To
|
~ | | avoid unnecessary database queries, these counts are cached, making it
|
~ | | very quick to determine whether a user has starred review requests. |
| ~ | get_starred_review_groups_count()
|
| ~ | get_starred_review_requests_count()
|
| ~ | has_starred_review_groups()
|
| + | has_starred_review_requests()
|
| + | is_review_group_starred()
|
| + | is_review_request_starred()
|
| |
|
~ | | The star/unstar methods will invalidate the cache count, recomputing the
|
~ | | next time the functions are called. |
| ~ | Both get_starred_review_groups_count() and
|
| ~ | get_starred_review_requests_count() return the number of starred
|
| + | groups/review requests for a given user and optional LocalSite . These
|
| + | values are cached, making subsequent lookups fast, and enabling
|
| + | decisions to be made based on the content. |
| |
|
~ | | The plan will be to incorporate this into some query building, in order
|
~ | | to avoid unnecessary JOINs. This will take place in a future change. |
| ~ | These are wrapped by has_starred_review_groups() and
|
| ~ | has_starred_review_requests() , which fetch the count and return whether
|
| + | there's at least 1 item. |
| + |
|
| + | is_review_group_starred() and is_review_request_starred() return
|
| + | whether a given review group or review request are starred. This queries
|
| + | the database as normal, but if the user hasn't starred any items of the
|
| + | given type, this won't perform a query at all. |
| + |
|
| + | The star/unstar methods will invalidate the cache count. |
| + |
|
| + | Most users don't star items, and likely don't star them very often. By
|
| + | caching, we can avoid a lot of lookups and simplify database queries for
|
| + | users (which will be implemented in another change). |