Skip to content

Commit

Permalink
Remove anon v1 full trending tracks cache (#6250)
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacsolo committed Oct 5, 2023
1 parent 139221f commit 46bc79a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
4 changes: 2 additions & 2 deletions discovery-provider/src/api/v1/tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
from src.queries.get_track_stream_signature import get_track_stream_signature
from src.queries.get_tracks import RouteArgs, get_tracks
from src.queries.get_tracks_including_unlisted import get_tracks_including_unlisted
from src.queries.get_trending import get_full_trending, get_trending
from src.queries.get_trending import get_trending
from src.queries.get_trending_ids import get_trending_ids
from src.queries.get_trending_tracks import TRENDING_LIMIT, TRENDING_TTL_SEC
from src.queries.get_unclaimed_id import get_unclaimed_id
Expand Down Expand Up @@ -683,7 +683,7 @@ def get(self, version):
strategy = trending_strategy_factory.get_strategy(
TrendingType.TRACKS, version_list[0]
)
trending_tracks = get_full_trending(request, args, strategy)
trending_tracks = get_trending(args, strategy)
return success_response(trending_tracks)


Expand Down
17 changes: 1 addition & 16 deletions discovery-provider/src/queries/get_trending.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import logging

from src.api.v1.helpers import extend_track, format_limit, format_offset, to_dict
from src.api.v1.helpers import extend_track, format_limit, format_offset
from src.premium_content.premium_content_constants import (
SHOULD_TRENDING_EXCLUDE_PREMIUM_TRACKS,
)
from src.queries.get_trending_tracks import (
TRENDING_LIMIT,
TRENDING_TTL_SEC,
get_trending_tracks,
)
from src.utils.helpers import decode_string_id # pylint: disable=C0302
from src.utils.redis_cache import get_trending_cache_key, use_redis_cache

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -39,16 +37,3 @@ def get_trending(args, strategy):

tracks = get_trending_tracks(args, strategy)
return list(map(extend_track, tracks))


def get_full_trending(request, args, strategy):
key = get_trending_cache_key(to_dict(request.args), request.path)

# Attempt to use the cached tracks list
if args["user_id"] is not None:
full_trending = get_trending(args, strategy)
else:
full_trending = use_redis_cache(
key, TRENDING_TTL_SEC, lambda: get_trending(args, strategy)
)
return full_trending

0 comments on commit 46bc79a

Please sign in to comment.