refactor stat fetching
This commit is contained in:
parent
6e1170b3ed
commit
15aacf88f7
1 changed files with 6 additions and 10 deletions
16
src/main.rs
16
src/main.rs
|
@ -16,18 +16,16 @@ fn get_job_stats(lodestone_id: usize) -> anyhow::Result<Vec<JobStats>> {
|
||||||
fn main() -> anyhow::Result<()> {
|
fn main() -> anyhow::Result<()> {
|
||||||
let id = 29932586;
|
let id = 29932586;
|
||||||
let stats = get_job_stats(id)?;
|
let stats = get_job_stats(id)?;
|
||||||
|
display_stats(id, &stats);
|
||||||
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}");
|
|
||||||
|
|
||||||
let id = 44540671;
|
let id = 44540671;
|
||||||
let stats = get_job_stats(id)?;
|
let stats = get_job_stats(id)?;
|
||||||
|
display_stats(id, &stats);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn display_stats(id: usize, stats: &[JobStats]) {
|
||||||
let total_dowm_earned_levels = stats
|
let total_dowm_earned_levels = stats
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|j| matches!(j.role, Role::Tank | Role::Healer | Role::Dps(_)))
|
.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);
|
.fold(0usize, |acc, j| acc + j.level - j.starting_level);
|
||||||
|
|
||||||
println!("{total_dowm_earned_levels} levels for {id}");
|
println!("{total_dowm_earned_levels} levels for {id}");
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue