feat: Reorder highlight items on favorite action#1133
Open
chethan2106 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR implements stable favorite ordering behavior for highlight set items so that favorites maintain deterministic insertion order and ranking updates correctly when items are unfavorited.
Related Jira: ENT-10610
Overview
This change updates highlight favorite toggling logic to enforce stable sort behavior for favorited items:
Changes Made
highlights.pyhighlights.pyhighlights.pyserializers.pytest_curation_views.pyImplementation Details
Favorite Toggle Logic
File:
highlights.pyValidates request inputs up front:
content_uuidfavoriteparameter (supports explicit booleanfalse)Uses
transaction.atomicwith row-level locks viaselect_for_updatefor consistency.On
favorite = true:sort_ordermax + 1), or0if this is the first favoriteOn
favorite = false:Resets unfavorited item:
sort_order = 0is_favorite = falseDecrements
sort_orderfor favorites ranked below the removed itemEnsures stable behavior under concurrent requests
Retrieval Ordering
Files:
highlights.pyserializers.pyAdded shared ordering tuple:
sort_ordercreatedPrefetches highlighted content using ordered queryset in the view layer
Serializer:
Tests Added / Updated
File:
test_curation_views.pyfavoriteaccepts booleanfalsesort_ordersort_ordercorrectlyAdditional CI Stability Updates Included
factories.pytest_tasks.pymodels.pyTesting
All mandatory checks passed locally:
make test make quality make validate python manage.py makemigrations --check --dry-run make check_keywordsAcceptance Criteria (ENT-10610)
Merge Checklist
Sample Response:
Sort Favourites.txt