Re-point profile/badge callers after identity merge
Browse files at this commit3abed0fccaadc4e96534fab3b69798da3f4d3dbeParent: 919680f- chore
- re-point profile/badge callers after identity merge
2 changed files +6 -6
- src/db/pomodoro.rs +2 -2
- src/web/users.rs +4 -4
src/db/pomodoro.rsmodified+2 -2
| @@ -663,7 +663,7 @@ mod tests { | ||
| 663 | 663 | // Every one of them is still the student's own history. |
| 664 | 664 | assert_eq!(list_for_user(&db, &user).await.unwrap().len(), 200); |
| 665 | 665 | assert!( |
| 666 | - badge::BadgeAward::list_for(&user, &db) | |
| 666 | + crate::db::badge::list_for(&db, &user) | |
| 667 | 667 | .await |
| 668 | 668 | .unwrap() |
| 669 | 669 | .is_empty(), |
| @@ -734,7 +734,7 @@ mod tests { | ||
| 734 | 734 | assert_eq!(closed.get_finished_at().unwrap().as_millis(), started); |
| 735 | 735 | |
| 736 | 736 | // And the stat that sums these stays non-negative. |
| 737 | - let stats = crate::domain::profile::ProfileStats::load(&user, 0, 0, &db) | |
| 737 | + let stats = crate::db::profile::load(&db, &user, 0, 0) | |
| 738 | 738 | .await |
| 739 | 739 | .unwrap(); |
| 740 | 740 | assert_eq!(stats.get_pomodoro_sessions(), 1); |
src/web/users.rsmodified+4 -4
| @@ -939,7 +939,7 @@ async fn profile_of( | ||
| 939 | 939 | let classes = ClassGroup::list_by_ids(&class_ids, &st.db).await?; |
| 940 | 940 | // Both totals are the full counts, not the windowed ones — the blocks are a |
| 941 | 941 | // preview, the stats are the truth. |
| 942 | - let stats = ProfileStats::load(id, course_total, class_total, &st.db).await?; | |
| 942 | + let stats = crate::service::profile::load(&st.db, id, course_total, class_total).await?; | |
| 943 | 943 | let badges = badges_of(st, id, &stats).await?; |
| 944 | 944 | Ok(ProfileResponse { |
| 945 | 945 | id: id.key().to_string(), |
| @@ -1017,20 +1017,20 @@ async fn badges_of( | ||
| 1017 | 1017 | user: &UserId, |
| 1018 | 1018 | stats: &ProfileStats, |
| 1019 | 1019 | ) -> Result<Vec<BadgeAward>, AppError> { |
| 1020 | - let awards = BadgeAward::list_for(user, &st.db).await?; | |
| 1020 | + let awards = crate::service::badge::list_for(&st.db, user).await?; | |
| 1021 | 1021 | let complete = badge::earned(stats.get_totals()) |
| 1022 | 1022 | .iter() |
| 1023 | 1023 | .all(|id| awards.iter().any(|award| award.get_badge() == *id)); |
| 1024 | 1024 | if complete { |
| 1025 | 1025 | return Ok(awards); |
| 1026 | 1026 | } |
| 1027 | - if let Err(err) = badge::sync(user, &st.db).await { | |
| 1027 | + if let Err(err) = crate::service::badge::sync(&st.db, user).await { | |
| 1028 | 1028 | tracing::warn!("failed to sync badges for {}: {err}", user.key()); |
| 1029 | 1029 | return Ok(awards); |
| 1030 | 1030 | } |
| 1031 | 1031 | // Re-read so the badge just healed appears on *this* response, stamp and |
| 1032 | 1032 | // all, rather than only on the next one. |
| 1033 | - BadgeAward::list_for(user, &st.db).await | |
| 1033 | + crate::service::badge::list_for(&st.db, user).await | |
| 1034 | 1034 | } |
| 1035 | 1035 | |
| 1036 | 1036 | /// The profile gate: any authenticated account reads any profile — except a |