|
@@ -68,7 +68,6 @@ struct Account {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
fn date_to_gcal(date: DateTime<Local>) -> String {
|
|
fn date_to_gcal(date: DateTime<Local>) -> String {
|
|
|
format!("{}",
|
|
format!("{}",
|
|
|
date.format("%Y%m%dT%H%M00/%Y%m%dT%H%M00")
|
|
date.format("%Y%m%dT%H%M00/%Y%m%dT%H%M00")
|
|
@@ -228,6 +227,17 @@ fn daemon(queries: Vec<Query>, loaded_auctions: Vec<Auction>) {
|
|
|
// let _s = loaded_auctions.into_iter().map(|x| (x.url.clone(), x.clone())).collect::<Vec<_>>();
|
|
// let _s = loaded_auctions.into_iter().map(|x| (x.url.clone(), x.clone())).collect::<Vec<_>>();
|
|
|
let mut auction_map: HashMap<String, Auction> = loaded_auctions.into_iter().map(|x| (x.url.clone(), x.clone())).collect();
|
|
let mut auction_map: HashMap<String, Auction> = loaded_auctions.into_iter().map(|x| (x.url.clone(), x.clone())).collect();
|
|
|
|
|
|
|
|
|
|
+ for (_key, mut auction) in auction_map {
|
|
|
|
|
+ if Utc::now().with_timezone(&Local).timestamp() > auction.timestamp {
|
|
|
|
|
+ //auction has expired, mark price as final
|
|
|
|
|
+ auction.is_price_final = true;
|
|
|
|
|
+ dbg!(&auction);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return;
|
|
|
println!("Starting daemon with {} active queries", queries.len());
|
|
println!("Starting daemon with {} active queries", queries.len());
|
|
|
loop {
|
|
loop {
|
|
|
// TODO: see if we can get rid of clone
|
|
// TODO: see if we can get rid of clone
|
|
@@ -241,13 +251,12 @@ fn daemon(queries: Vec<Query>, loaded_auctions: Vec<Auction>) {
|
|
|
dbg!(&auction.desc);
|
|
dbg!(&auction.desc);
|
|
|
let a = auction.clone();
|
|
let a = auction.clone();
|
|
|
auction_map.insert(auction.url, a);
|
|
auction_map.insert(auction.url, a);
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
println!("{} auctions found", &auction_map.len());
|
|
println!("{} auctions found", &auction_map.len());
|
|
|
let writer = BufWriter::new(File::create("db.json").unwrap());
|
|
let writer = BufWriter::new(File::create("db.json").unwrap());
|
|
|
|
|
|
|
|
- let mut auctions: Vec<Auction> = auction_map.into_iter().map(|(x,y)| y).collect();
|
|
|
|
|
|
|
+ let mut auctions: Vec<Auction> = auction_map.into_iter().map(|(_x, y)| y).collect();
|
|
|
auctions.sort_by_key(|k| k.remaining);
|
|
auctions.sort_by_key(|k| k.remaining);
|
|
|
|
|
|
|
|
serde_json::to_writer_pretty(writer, &auctions).unwrap();
|
|
serde_json::to_writer_pretty(writer, &auctions).unwrap();
|