Skip to content

Commit

Permalink
feat: include rating words in dashboard ui
Browse files Browse the repository at this point in the history
  • Loading branch information
BrewingWeasel committed Aug 1, 2024
1 parent ef459e2 commit 41d9b32
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src-tauri/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ pub async fn time_spent(state: State<'_, SakinyjeState>) -> Result<TimeSpentStat
})
}

const WORD_RATING: [&str; 4] = ["Learning", "Recognized", "Familiar", "Known"];

#[tauri::command]
pub async fn get_words_known_at_levels(
state: State<'_, SakinyjeState>,
Expand All @@ -76,7 +78,7 @@ pub async fn get_words_known_at_levels(
.get(current_language)
.expect("language to include")
.words;
let mut words_at_rating = [0; 5];
let mut words_at_rating = [0; 4];
for info in words.values() {
match info.rating {
-1 | 0 => (),
Expand All @@ -89,7 +91,7 @@ pub async fn get_words_known_at_levels(
.iter()
.enumerate()
.map(|(rating, amount)| NumWordsKnown {
name: format!("words rated {}", rating + 1),
name: format!("{} words", WORD_RATING[rating]),
amount: *amount,
})
.collect())
Expand Down

0 comments on commit 41d9b32

Please sign in to comment.