fix(achievements): follower_gain progress uses absolute follower count#3995
Merged
Conversation
The Prophet/Shepherd achievements (follower_gain) were being incremented by +1 on every follow event and never decremented on unfollow, causing progress to drift far above a user's real follower count (e.g. 99/100 shown for a user with 15 followers). - Add AchievementEventType.FollowerGain to absoluteValueEventTypes so checkAchievementProgress sets progress to the true follower count (already computed and passed as currentValue) instead of incrementing. - Align the live follower count filter to status IN (follow, subscribed) to match the retroactive backfill handler. Fixes ENG-1796
|
🍹 The Update (preview) for dailydotdev/api/prod (at 9c0c120) was successful. Resource Changes Name Type Operation
~ vpc-native-channel-highlights-cron kubernetes:batch/v1:CronJob update
~ vpc-native-user-profile-analytics-history-clickhouse-cron kubernetes:batch/v1:CronJob update
~ vpc-native-hourly-notification-cron kubernetes:batch/v1:CronJob update
~ vpc-native-update-trending-cron kubernetes:batch/v1:CronJob update
~ vpc-native-calculate-top-readers-cron kubernetes:batch/v1:CronJob update
~ vpc-native-personalized-digest-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-clean-old-notifications-cron kubernetes:batch/v1:CronJob update
- vpc-native-api-clickhouse-migration-46e10cfe kubernetes:batch/v1:Job delete
~ vpc-native-update-tags-str-cron kubernetes:batch/v1:CronJob update
~ vpc-native-daily-digest-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-zombie-user-companies-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-zombie-images-cron kubernetes:batch/v1:CronJob update
~ vpc-native-private-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-user-profile-analytics-clickhouse-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-zombie-users-cron kubernetes:batch/v1:CronJob update
~ vpc-native-rotate-daily-quests-cron kubernetes:batch/v1:CronJob update
~ vpc-native-bg-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-sync-subscription-with-cio-cron kubernetes:batch/v1:CronJob update
~ vpc-native-materialize-yearly-best-post-archives-cron kubernetes:batch/v1:CronJob update
- vpc-native-api-db-migration-46e10cfe kubernetes:batch/v1:Job delete
+ vpc-native-api-db-migration-9c4cf9e0 kubernetes:batch/v1:Job create
~ vpc-native-update-achievement-rarity-cron kubernetes:batch/v1:CronJob update
~ vpc-native-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-clean-zombie-opportunities-cron kubernetes:batch/v1:CronJob update
~ vpc-native-expire-super-agent-trial-cron kubernetes:batch/v1:CronJob update
~ vpc-native-squad-posts-analytics-refresh-cron kubernetes:batch/v1:CronJob update
~ vpc-native-post-analytics-clickhouse-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-channel-highlights-cron kubernetes:batch/v1:CronJob update
~ vpc-native-personalized-digest-cron kubernetes:batch/v1:CronJob update
~ vpc-native-update-current-streak-cron kubernetes:batch/v1:CronJob update
~ vpc-native-worker-job-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-post-analytics-history-day-clickhouse-cron kubernetes:batch/v1:CronJob update
~ vpc-native-post-analytics-achievements-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-gifted-plus-cron kubernetes:batch/v1:CronJob update
~ vpc-native-user-profile-updated-sync-cron kubernetes:batch/v1:CronJob update
~ vpc-native-materialize-monthly-best-post-archives-cron kubernetes:batch/v1:CronJob update
~ vpc-native-update-source-public-threshold-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-expired-better-auth-sessions-cron kubernetes:batch/v1:CronJob update
~ vpc-native-user-posts-analytics-refresh-cron kubernetes:batch/v1:CronJob update
~ vpc-native-update-views-cron kubernetes:batch/v1:CronJob update
+ vpc-native-api-clickhouse-migration-9c4cf9e0 kubernetes:batch/v1:Job create
... and 15 other changes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
User feedback (ENG-1796): the Prophet achievement ("Gain 100 followers") showed 99/100 progress for a user with only 15 followers.
Root cause
follower_gainachievements (Prophet, Shepherd) are evaluated incheckAchievementProgress, butAchievementEventType.FollowerGainwas missing fromabsoluteValueEventTypes. As a result:onContentPreferenceChange) computes the realfollowerCountand passes it ascurrentValue, but the code fell through to the milestone evaluator, which ignorescurrentValueand just doesprogress += 1on every follow event.op === 'd') only Quest progress is decremented — the achievement progress is never brought back down.So progress increments on every follow and never decrements, drifting far above the real follower count over follow/unfollow churn.
The retroactive backfill handler (
handleFollowerGain) already does it correctly — it countscontent_preferencewherestatus IN ('follow','subscribed')and sets progress to that absolute value. The live path and the backfill disagreed.Fix
AchievementEventType.FollowerGaintoabsoluteValueEventTypesso progress is set to the true follower count (already computed and passed ascurrentValue) instead of incremented.primary.tstostatus IN (follow, subscribed)to match the retroactive handler.Follow-up (not in this PR)
Re-run the
FollowerGainretroactive sync to correct users whose progress already drifted (e.g. the reporter would go from 99 back to 15).Fixes ENG-1796