use lodestone-fetcher

main
Zynh0722 2024-02-25 14:33:13 -08:00
parent 3811f0af15
commit 0c75859cd2
1 changed files with 8 additions and 3 deletions

View File

@ -4,11 +4,16 @@ mod raw_data;
use crate::compile_data::{DpsRole, JobStats, Role};
use crate::raw_data::RawJobStats;
use std::fs::File;
use std::process::{Command, Stdio};
fn get_job_stats(lodestone_id: usize) -> anyhow::Result<Vec<JobStats>> {
let file = File::open(format!("./data/{lodestone_id}.json"))?;
let raw: Vec<RawJobStats> = serde_json::from_reader(file)?;
let output = Command::new("lodestone-fetcher")
.arg(lodestone_id.to_string())
.stdout(Stdio::piped())
.output()
.expect("Failed to execute lodestone-fetcher");
let raw: Vec<RawJobStats> = serde_json::from_reader(&output.stdout[..])?;
Ok(raw.into_iter().map(|r| r.into()).collect())
}