forge
Explore
Log in

Don't you dare go Hollow

Re-point profile/badge callers after identity merge

Browse files at this commit

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