Skip to content

Commit

Permalink
fix: struct UserAchievements
Browse files Browse the repository at this point in the history
  • Loading branch information
irisdv committed Oct 24, 2023
1 parent f14ba4f commit 65efbee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/endpoints/achievements/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ pub async fn handler(
match result {
Ok(document) => {
if let Ok(achievement) = from_document::<UserAchievements>(document) {
if !achievement.category_disabled.unwrap_or(false) {
if !achievement.category_disabled {
achievements.push(achievement);
}
}
Expand Down
12 changes: 9 additions & 3 deletions src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,20 @@ pub_struct!(Debug, Serialize, Deserialize; AchievementCategoryDocument {
img_url: String,
});

pub_struct!(Debug, Serialize, Deserialize; UserAchievements {
#[derive(Debug, Serialize, Deserialize)]
pub struct UserAchievements {
category_name: String,
category_desc: String,
category_img_url: String,
category_type: String,
category_disabled: Option<bool>,
#[serde(default = "default_category_disabled")]
pub category_disabled: bool,
achievements: Vec<UserAchievement>,
});
}

pub fn default_category_disabled() -> bool {
false
}

pub_struct!(Debug, Serialize, Deserialize; UserAchievement {
id: u32,
Expand Down

0 comments on commit 65efbee

Please sign in to comment.