From 6a4e9f918b7833c75398c0d37e2c1b4414e5fcb0 Mon Sep 17 00:00:00 2001 From: Badewanne3 <41148446+MaxOhn@users.noreply.github.com> Date: Thu, 25 Jul 2024 13:37:45 +0200 Subject: [PATCH] feat!: add daily challenge user stats (#33) --- src/model/user.rs | 25 +++++++++++++++++++++++++ tests/serde.rs | 12 ++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/model/user.rs b/src/model/user.rs index d30da2e..0999383 100644 --- a/src/model/user.rs +++ b/src/model/user.rs @@ -109,6 +109,29 @@ where d.deserialize_option(OptionCountryVisitor) } +#[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize)] +#[cfg_attr(feature = "serialize", derive(serde::Serialize))] +pub struct DailyChallengeUserStatistics { + pub daily_streak_best: u32, + pub daily_streak_current: u32, + #[serde( + skip_serializing_if = "Option::is_none", + with = "serde_util::option_datetime" + )] + pub last_update: Option, + #[serde( + skip_serializing_if = "Option::is_none", + with = "serde_util::option_datetime" + )] + pub last_weekly_streak: Option, + pub playcount: u32, + pub top_10p_placements: u32, + pub top_50p_placements: u32, + pub user_id: u32, + pub weekly_streak_best: u32, + pub weekly_streak_current: u32, +} + /// Counts of grades of a [`UserExtended`]. #[derive(Clone, Debug, Deserialize, Eq, PartialEq)] #[cfg_attr(feature = "serialize", derive(serde::Serialize))] @@ -357,6 +380,8 @@ pub struct UserExtended { pub badges: Option>, #[serde(default, skip_serializing_if = "Option::is_none")] pub beatmap_playcounts_count: Option, + #[serde(rename = "daily_challenge_user_stats")] + pub daily_challenge_stats: DailyChallengeUserStatistics, #[serde( default, rename = "favourite_beatmapset_count", diff --git a/tests/serde.rs b/tests/serde.rs index 00837eb..211ff7e 100644 --- a/tests/serde.rs +++ b/tests/serde.rs @@ -688,6 +688,18 @@ mod types { url: String::new(), }]), beatmap_playcounts_count: Some(3), + daily_challenge_stats: DailyChallengeUserStatistics { + daily_streak_best: 123, + daily_streak_current: 123, + last_update: Some(get_date()), + last_weekly_streak: Some(get_date()), + playcount: 123, + top_10p_placements: 123, + top_50p_placements: 123, + user_id: 123, + weekly_streak_best: 123, + weekly_streak_current: 123, + }, favourite_mapset_count: Some(3), follower_count: Some(2), graveyard_mapset_count: Some(8),