Skip to content

Commit

Permalink
[PAY-2361] Fix search es with new gated fields (#7230)
Browse files Browse the repository at this point in the history
Co-authored-by: Saliou Diallo <saliou@audius.co>
  • Loading branch information
sddioulde and Saliou Diallo authored Jan 18, 2024
1 parent 5d97832 commit f6ad76f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/discovery-provider/src/queries/query_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ def populate_track_metadata(


def _populate_gated_track_metadata(session, tracks, current_user_id):
if not tracks:
if not tracks or not current_user_id:
return

current_user_wallet = (
Expand Down
7 changes: 7 additions & 0 deletions packages/discovery-provider/src/queries/search_es.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from src.api.v1.helpers import extend_playlist, extend_track, extend_user
from src.queries.get_feed_es import fetch_followed_saves_and_reposts, item_key
from src.queries.query_helpers import _populate_gated_track_metadata
from src.utils.db_session import get_db_read_replica
from src.utils.elasticdsl import (
ES_PLAYLISTS,
ES_TRACKS,
Expand Down Expand Up @@ -287,6 +289,11 @@ def finalize_response(
hydrate_saves_reposts(tracks, follow_saves, follow_reposts)
response[k] = [map_track(track, current_user) for track in tracks]

# batch populate gated track metadata
db = get_db_read_replica()
with db.scoped_session() as session:
_populate_gated_track_metadata(session, response[k], current_user_id)

# users: finalize
for k in ["users", "followed_users"]:
users = drop_copycats(response[k])
Expand Down
2 changes: 1 addition & 1 deletion packages/es-indexer/src/indexNames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ export const indexNames = {
playlists: 'playlists18',
reposts: 'reposts13',
saves: 'saves13',
tracks: 'tracks17',
tracks: 'tracks18',
users: 'users16',
}

0 comments on commit f6ad76f

Please sign in to comment.