Skip to content

Commit

Permalink
Revert "[PAY-3705] Fix search playlists expanding tracks (#10780)"
Browse files Browse the repository at this point in the history
This reverts commit 531efe1.
  • Loading branch information
raymondjacobson committed Dec 23, 2024
1 parent 070aa09 commit b226d02
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
8 changes: 2 additions & 6 deletions packages/discovery-provider/src/queries/get_feed_es.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,11 @@ def get_feed_es(args, limit=10, offset=0):
# batch populate gated track and collection metadata
db = get_db_read_replica()
with db.scoped_session() as session:
_populate_gated_content_metadata(
session, sorted_feed, current_user["user_id"], include_playlist_tracks=True
)
_populate_gated_content_metadata(session, sorted_feed, current_user["user_id"])

# populate metadata + remove extra fields from items
sorted_feed = [
populate_track_or_playlist_metadata_es(
item, current_user, include_playlist_tracks=True
)
populate_track_or_playlist_metadata_es(item, current_user)
for item in sorted_feed
]

Expand Down
6 changes: 2 additions & 4 deletions packages/discovery-provider/src/queries/query_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,9 +737,7 @@ def get_content_url_with_mirrors(
}


def _populate_gated_content_metadata(
session, entities, current_user_id, include_playlist_tracks=False
):
def _populate_gated_content_metadata(session, entities, current_user_id):
"""Checks if `current_user_id` has access to each entity and populates relevant fields.
Responsible for populating the `access` field of both tracks and playlists.
Expand Down Expand Up @@ -859,7 +857,7 @@ def getContentId(metadata):
] = has_download_access

for entity in entities:
if "playlist_id" in entity and "tracks" in entity and include_playlist_tracks:
if "playlist_id" in entity and "tracks" in entity:
_populate_gated_content_metadata(session, entity["tracks"], current_user_id)
content_id = getContentId(entity)
if content_id not in gated_content_ids:
Expand Down
6 changes: 2 additions & 4 deletions packages/discovery-provider/src/utils/elasticdsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ def populate_user_metadata_es(user, current_user):
return omit_indexed_fields(user)


def populate_track_or_playlist_metadata_es(
item, current_user, include_playlist_tracks=False
):
def populate_track_or_playlist_metadata_es(item, current_user):
if current_user:
my_id = current_user["user_id"]
item["has_current_user_reposted"] = my_id in item.get("reposted_by", [])
Expand All @@ -85,7 +83,7 @@ def populate_track_or_playlist_metadata_es(
item["followee_reposts"] = item.get("followee_reposts", [])
item["followee_saves"] = item.get("followee_saves", [])

if "playlist_id" in item and "tracks" in item and include_playlist_tracks:
if "playlist_id" in item and "tracks" in item:
item["tracks"] = [
populate_track_or_playlist_metadata_es(track, current_user)
for track in item["tracks"]
Expand Down

0 comments on commit b226d02

Please sign in to comment.