Skip to content

Commit

Permalink
feat!: add daily challenge user stats (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxOhn authored Jul 25, 2024
1 parent 04744c6 commit 6a4e9f9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/model/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<OffsetDateTime>,
#[serde(
skip_serializing_if = "Option::is_none",
with = "serde_util::option_datetime"
)]
pub last_weekly_streak: Option<OffsetDateTime>,
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))]
Expand Down Expand Up @@ -357,6 +380,8 @@ pub struct UserExtended {
pub badges: Option<Vec<Badge>>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub beatmap_playcounts_count: Option<u32>,
#[serde(rename = "daily_challenge_user_stats")]
pub daily_challenge_stats: DailyChallengeUserStatistics,
#[serde(
default,
rename = "favourite_beatmapset_count",
Expand Down
12 changes: 12 additions & 0 deletions tests/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 6a4e9f9

Please sign in to comment.