Uh oh!
There was an error while loading. Please reload this page.
[PAY-3954] Add backend for play count challenge - #11473
Conversation
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
dharit-tan
left a comment
There was a problem hiding this comment.
- what happens if when the first time this job is run, the user already has more than 250 plays?
- could you write a test file for this challenge? maybe the case above is a good test case.
| ) | ||
| # Get the track owner ID for the track_played event | ||
| track = ( |
There was a problem hiding this comment.
nit: is there a way we can move this query into the challenge manager itself instead of here? not sure if possible if user_id is required in the challenge bus dispatch.
There was a problem hiding this comment.
OR: can we attach the new challenge to track_listen event instead of adding new track_played event?
There was a problem hiding this comment.
just double-checking: the owner_id isn't available from the play event right? just would like to avoid this query if possible. i don't think there's a way around having 2 separate challenge event types tho.
There was a problem hiding this comment.
yea no owner_id
classPlayInfo(TypedDict):
user_id: int|Noneplay_item_id: intcreated_at: datetimeupdated_at: datetimesource: strcity: strregion: strcountry: strslot: intsignature: strThere was a problem hiding this comment.
yeah we don't pass the owner of the track id with the play event, the user_id in there is the user that performed the listen
| timestamp = datetime.now().strftime("%Y%m%d%H%M%S") | ||
| key = f"{hex(user_id)[2:]}" | ||
| # If user has already completed the final milestone, don't create a new challenge |
There was a problem hiding this comment.
nit: could move this up to line 140
| if total_challenges >= len(PLAY_MILESTONES): | ||
| return False | ||
| sorted_milestones = sorted(PLAY_MILESTONES.keys()) |
There was a problem hiding this comment.
i think what you have is fine, but i feel like we're doing duplicate work in this fn + update_user_challenges. not sure we need this logic from 187 onwards..
if total_challenges < len(PLAY_MILESTONES) then isn't it safe to create the challenge row but have it marked false? ah but then in generate_specifier we don't actually go grab the next relevant challenge so maybe that won't work.
just thinking out loud, maybe there's a way to avoid the double work, but maybe this is fine. If we get into a scenario where we create a user_challenge row with is_complete = False, would that break things? i think you're successfully avoiding that here though.
There was a problem hiding this comment.
i think i remember going down a similar path and having records that weren't supposed to exist being created so went down this path for proper challenge creation
dharit-tan
left a comment
There was a problem hiding this comment.
approved pending specifier update
[d05de12] Fix missing cover-photo error log (#11512) Raymond Jacobson [3c02192] Remove invalid model fields for create track/playlist notifs (#11511) Randy Schott [e4056ed] Make stage first weekly comment backend match prod (#11508) Reed [ed24d42] Use cross fetch in AAO plugin (#11505) Isaac Solo [327e915] Enable stage AAO plugin config (#11502) Isaac Solo [18a5dea] AAO UI (#11499) Steve Perkins [3656b57] indexing side effects (#11492) alecsavvy [1ec83cc] [PAY-3954] Add backend for play count challenge (#11473) Farid Salau
Description
This PR implements a new challenge system that rewards artists when their tracks reach specific play count milestones in 2025. The challenge tracks play counts across all of an artist's tracks and awards $AUDIO tokens when they reach predefined thresholds.
Implementation Details
track_playedthat fires when anyone listens to an artist's trackplay_count_milestones_challenge_managerto handle milestone trackingConfiguration
Notes
How Has This Been Tested?