refactor stat fetching

This commit is contained in:
Zynh0722 2024-02-02 13:09:24 -08:00
parent 6e1170b3ed
commit 15aacf88f7

View file

@ -16,18 +16,16 @@ fn get_job_stats(lodestone_id: usize) -> anyhow::Result<Vec<JobStats>> {
fn main() -> anyhow::Result<()> {
let id = 29932586;
let stats = get_job_stats(id)?;
let total_dowm_earned_levels = stats
.iter()
.filter(|j| matches!(j.role, Role::Tank | Role::Healer | Role::Dps(_)))
.filter(|j| j.name != "Scholar")
.fold(0usize, |acc, j| acc + j.level - j.starting_level);
println!("{total_dowm_earned_levels} levels for {id}");
display_stats(id, &stats);
let id = 44540671;
let stats = get_job_stats(id)?;
display_stats(id, &stats);
Ok(())
}
fn display_stats(id: usize, stats: &[JobStats]) {
let total_dowm_earned_levels = stats
.iter()
.filter(|j| matches!(j.role, Role::Tank | Role::Healer | Role::Dps(_)))
@ -35,6 +33,4 @@ fn main() -> anyhow::Result<()> {
.fold(0usize, |acc, j| acc + j.level - j.starting_level);
println!("{total_dowm_earned_levels} levels for {id}");
Ok(())
}