-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9274a5c
commit 7cb7249
Showing
6 changed files
with
100 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
node_modules | ||
.idea/ | ||
lowestbins.json | ||
debug.log | ||
info.log |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,40 @@ | ||
use crate::bazaar::get as get_bazaar; | ||
use crate::util::{get, parse_hypixel}; | ||
use log::{debug, info}; | ||
use std::collections::HashMap; | ||
use std::fs; | ||
use std::time::Instant; | ||
|
||
pub async fn fetch_auctions() { | ||
info!("fetching auctions"); | ||
let started = Instant::now(); | ||
|
||
let mut auctions: HashMap<String, i64> = HashMap::new(); | ||
|
||
let r = get(1).await; | ||
auctions = parse_hypixel(r.auctions, auctions); | ||
for a in 2..r.total_pages { | ||
println!("------------------------ req: {}", a); | ||
debug!("------------------------ req: {}", a); | ||
let now = Instant::now(); | ||
let r = get(a).await; | ||
println!(": request took {} miliseconds", now.elapsed().as_millis()); | ||
debug!(": request took {} miliseconds", now.elapsed().as_millis()); | ||
let nowss = Instant::now(); | ||
auctions = parse_hypixel(r.auctions, auctions); | ||
println!("$ parsing took {} miliseconds", nowss.elapsed().as_millis()); | ||
println!( | ||
debug!("$ parsing took {} miliseconds", nowss.elapsed().as_millis()); | ||
debug!( | ||
"! request and parsing took {} miliseconds", | ||
now.elapsed().as_millis() | ||
); | ||
} | ||
info!("fetching bazaar"); | ||
let r = get_bazaar().await; | ||
let prods = r.products; | ||
for (key, val) in prods.iter() { | ||
auctions.insert(key.to_string(), val.quick_status.buy_price.round() as i64); | ||
} | ||
|
||
let xs = serde_json::to_string(&auctions).unwrap(); | ||
println!("writing file"); | ||
println!("!! Total time taken {}", started.elapsed().as_secs()); | ||
debug!("writing file"); | ||
info!("!! Total time taken {}", started.elapsed().as_secs()); | ||
fs::write("lowestbins.json", xs).unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters