Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion discovery-provider/src/queries/get_trending_tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ def generate_unpopulated_trending_from_mat_views(
top_listen_tracks_subquery = top_listen_tracks_subquery.order_by(
desc(AggregateIntervalPlay.year_listen_counts)
)
top_listen_tracks_subquery = top_listen_tracks_subquery.limit(limit)

score_params = strategy.get_score_params()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yes, the net multiplier is good

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need the net multiplier at all though? can we issue this request without a top listen subquery?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in line w/ the "one experiment" thing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This top listen tracks with the net multiplier is strictly to keep the trending consistent with the current trending algorithm.
The current trending gets the top X (100* net_multiplier) tracks and scores / sorts those and then takes the top 100.
This new trending scheme with the DB track trending score does not need this at all. It was previously done as a heuristic to make it more performant, but we do it to keep the trending consistent.

nm = score_params["nm"]

top_listen_tracks_subquery = top_listen_tracks_subquery.limit(limit * nm)

trending_track_ids_query = session.query(
TrackTrendingScore.track_id, TrackTrendingScore.score
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def update_track_score_query(self, session):
CASE
WHEN tp.owner_follower_count < :y
THEN 0
WHEN (now()::date - aip.created_at::date) > :week
THEN greatest(1.0/:q, pow(:q, 1.0 - 1.0*(now()::date - aip.created_at::date)/:week)) * (:N * aip.week_listen_counts + :F * tp.repost_week_count + :O * tp.save_week_count + :R * tp.repost_count + :i * tp.save_count) * tp.karma
WHEN EXTRACT(DAYS from now() - aip.created_at) > :week
THEN greatest(1.0/:q, pow(:q, greatest(-10, 1.0 - 1.0*EXTRACT(DAYS from now() - aip.created_at)/:week))) * (:N * aip.week_listen_counts + :F * tp.repost_week_count + :O * tp.save_week_count + :R * tp.repost_count + :i * tp.save_count) * tp.karma
ELSE (:N * aip.week_listen_counts + :F * tp.repost_week_count + :O * tp.save_week_count + :R * tp.repost_count + :i * tp.save_count) * tp.karma
END as week_score,
now()
Expand All @@ -67,8 +67,8 @@ def update_track_score_query(self, session):
CASE
WHEN tp.owner_follower_count < :y
THEN 0
WHEN (now()::date - aip.created_at::date) > :month
THEN greatest(1.0/:q, pow(:q, 1.0 - 1.0*(now()::date - aip.created_at::date)/:month)) * (:N * aip.month_listen_counts + :F * tp.repost_month_count + :O * tp.save_month_count + :R * tp.repost_count + :i * tp.save_count) * tp.karma
WHEN EXTRACT(DAYS from now() - aip.created_at) > :month
THEN greatest(1.0/:q, pow(:q, greatest(-10, 1.0 - 1.0*EXTRACT(DAYS from now() - aip.created_at)/:month))) * (:N * aip.month_listen_counts + :F * tp.repost_month_count + :O * tp.save_month_count + :R * tp.repost_count + :i * tp.save_count) * tp.karma
ELSE (:N * aip.month_listen_counts + :F * tp.repost_month_count + :O * tp.save_month_count + :R * tp.repost_count + :i * tp.save_count) * tp.karma
END as month_score,
now()
Expand All @@ -86,8 +86,8 @@ def update_track_score_query(self, session):
CASE
WHEN tp.owner_follower_count < :y
THEN 0
WHEN (now()::date - aip.created_at::date) > :year
THEN greatest(1.0/:q, pow(:q, 1.0 - 1.0*(now()::date - aip.created_at::date)/:year)) * (:N * aip.year_listen_counts + :F * tp.repost_year_count + :O * tp.save_year_count + :R * tp.repost_count + :i * tp.save_count) * tp.karma
WHEN EXTRACT(DAYS from now() - aip.created_at) > :year
THEN greatest(1.0/:q, pow(:q, greatest(-10, 1.0 - 1.0*EXTRACT(DAYS from now() - aip.created_at)/:year))) * (:N * aip.year_listen_counts + :F * tp.repost_year_count + :O * tp.save_year_count + :R * tp.repost_count + :i * tp.save_count) * tp.karma
ELSE (:N * aip.year_listen_counts + :F * tp.repost_year_count + :O * tp.save_year_count + :R * tp.repost_count + :i * tp.save_count) * tp.karma
END as year_score,
now()
Expand Down