Skip to content
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

Fix entity manager playlist invalidation #3756

Merged
merged 2 commits into from
Aug 25, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions discovery-provider/src/tasks/entity_manager/entity_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,14 @@ def entity_manager_update(
records_to_save = []
for playlist_records in new_records["playlists"].values():
# invalidate all playlists besides the last one
for record in playlist_records:
record.is_current = False
for i in range(len(playlist_records)):
playlist_records[i].is_current = False

# invalidate existing record only if it's being updated
existing_playlist_id = playlist_records[0].playlist_id
raymondjacobson marked this conversation as resolved.
Show resolved Hide resolved
if existing_playlist_id in existing_records["playlists"]:
existing_records["playlists"][existing_playlist_id].is_current = False

# flip is_current to true for the last tx in each playlist
playlist_records[-1].is_current = True
records_to_save.extend(playlist_records)
Expand Down