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

Remove end_date on play count challenge and update query #11563

Merged
merged 3 commits into from
Mar 10, 2025
Merged

Conversation

faridsalau
Copy link
Contributor

Description

We are limiting earnings for play count from 2025 and beyond. Removing the end_date constraint so users can earn the reward post 2025.

How Has This Been Tested?

Copy link

changeset-bot bot commented Mar 10, 2025

⚠️ No Changeset found

Latest commit: a243f47

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@@ -38,7 +37,7 @@ def _get_user_play_count_2025(self, session: Session, user_id: int) -> int:
Track.is_delete == False,
),
)
.filter(and_(Play.created_at >= start_date, Play.created_at < end_date))
.filter(Play.created_at >= start_date)
Copy link
Member

Choose a reason for hiding this comment

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

i'm worried about this being slow. it is a very very hot path. like will run every time a single play event happens.

this query would be a lot faster if we ran it against the aggregate_monthly_plays table.

select count("plays"."id") from "plays"
join "tracks"
on "tracks"."track_id" = "plays"."play_item_id"
where "tracks"."owner_id" = 1

Ran for > 1 minute. No results on prod data.

select sum("count") from "aggregate_monthly_plays"
where "play_item_id" in (select "track_id" from "tracks" where "owner_id" = 1)
and "timestamp" > '2025-01-01'

300ms

Copy link
Member

Choose a reason for hiding this comment

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

update: it took 1 minute 51 sec

Copy link
Contributor

Choose a reason for hiding this comment

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

agree - one downside tho is that if aggregate_plays is behind on one node for some reason, we might get inconsistencies between DNs.
but that's probably the tradeoff we have to live with.. since many plays should be coming in eventually they should end up in the same state.

@faridsalau faridsalau changed the title Remove end_date on play count challenge Remove end_date on play count challenge and update query Mar 10, 2025
@faridsalau faridsalau enabled auto-merge (squash) March 10, 2025 19:57
@pull-request-size pull-request-size bot added size/L and removed size/M labels Mar 10, 2025
@faridsalau faridsalau merged commit 6fc5376 into main Mar 10, 2025
6 checks passed
@faridsalau faridsalau deleted the fs-remove-end branch March 10, 2025 21:03
schottra added a commit that referenced this pull request Mar 11, 2025
* origin/main:
  Remove prop in PlayCountMilestoneContent causing type error (#11575)
  dual write to acdc and core (#11573)
  [C-5828] Fix useQueries default loading state (#11569)
  fix attest endpoint (#11552)
  Fix unlocked gated content section on web (#11568)
  Remove end_date on play count challenge and update query (#11563)
audius-infra pushed a commit that referenced this pull request Mar 11, 2025
[4a0e8cc] dual write to acdc and core (#11573) alecsavvy
[2f859fb] fix attest endpoint (#11552) Steve Perkins
[6fc5376] Remove end_date on play count challenge and update query (#11563) Farid Salau
[5bebab8] [PAY-3893][PAY-3894] Remove legacy indexing of associated_wallets and collectibles (#11564) Randy Schott
[00a19f0] Fix marshalling for playlist notifs (#11562) Randy Schott
[ba9b8fb] Delete pc challenge (#11561) Farid Salau
[84eb2f8] [PAY-3979][PAY-3990] Update play count challenge BE and Add the FE (#11521) Farid Salau
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants