Skip to content

Commit

Permalink
Fix streak_ends and notify user_index (#6002)
Browse files Browse the repository at this point in the history
  • Loading branch information
megrogan authored Jul 8, 2024
1 parent 3760247 commit 0e75ea5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions backend/canisters/user/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Disable notifying about empty users until known empty users deleted ([#5996](https://github.com/open-chat-labs/open-chat/pull/5996))
- Delete user accounts that are empty and dormant ([#5985](https://github.com/open-chat-labs/open-chat/pull/5985))

### Fixed

- Fix `streak_ends` and notify `user_index` ([#6002](https://github.com/open-chat-labs/open-chat/pull/6002))

## [[2.0.1222](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1222-user)] - 2024-07-03

### Changed
Expand Down
6 changes: 6 additions & 0 deletions backend/canisters/user/impl/src/lifecycle/post_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,14 @@ fn fix_achievements(state: &mut RuntimeState) {

if lifetime_diamond && state.data.award_achievement(Achievement::UpgradedToGoldDiamond, now) {
ic_cdk_timers::set_timer(Duration::ZERO, notify_user_index_of_chit);
return;
}
}

if state.data.streak.days(now) > 0 {
// Fix the streak_ends for the user record in the user_index
ic_cdk_timers::set_timer(Duration::ZERO, notify_user_index_of_chit);
}
}

fn notify_user_index_of_chit() {
Expand Down
2 changes: 1 addition & 1 deletion backend/canisters/user/impl/src/model/streak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl Streak {
}

pub fn ends(&self) -> TimestampMillis {
Streak::day_to_timestamp(self.end_day + 1)
Streak::day_to_timestamp(self.end_day + 2)
}

pub fn claim(&mut self, now: TimestampMillis) -> bool {
Expand Down

0 comments on commit 0e75ea5

Please sign in to comment.