Ver código fonte

Don't list obsolete items

Johann Woelper 7 anos atrás
pai
commit
1d980bf253
2 arquivos alterados com 13 adições e 4 exclusões
  1. 1 1
      index.html
  2. 12 3
      src/main.rs

+ 1 - 1
index.html

@@ -50,7 +50,7 @@
     
     <div class="content">
       
-      <template v-for="item in items" v-if="item.price != null">
+      <template v-for="item in items" v-if="item.price != null && !item.is_price_final">
         <div class="panel">
           <div class="grid-auto">
             <div >

+ 12 - 3
src/main.rs

@@ -68,7 +68,6 @@ struct Account {
 }
 
 
-
 fn date_to_gcal(date: DateTime<Local>) -> String {
     format!("{}",
         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 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());
     loop {
         // 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);
                 let a = auction.clone();
                 auction_map.insert(auction.url, a);
-
             }
         }
         println!("{} auctions found", &auction_map.len());
         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);
 
         serde_json::to_writer_pretty(writer, &auctions).unwrap();