Parcourir la source

refactor old auction detection

Johann Woelper il y a 7 ans
Parent
commit
103f8d0c29
1 fichiers modifiés avec 23 ajouts et 10 suppressions
  1. 23 10
      src/main.rs

+ 23 - 10
src/main.rs

@@ -225,19 +225,32 @@ fn daemon(queries: Vec<Query>, loaded_auctions: Vec<Auction>) {
     
     // dbg!(&queries);
     // 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);
-        } 
 
-    }
 
+    // for auction in loaded_auctions {
+    //     if Utc::now().with_timezone(&Local).timestamp() > auction.timestamp {
+    //         //auction has expired, mark price as final
+    //         auction.is_price_final = true;
+    //         // let a = auction_map.get_mut(_key);
+    //         dbg!(&auction);
+    //     } 
+    // }
+
+    let auction_map: HashMap<String, Auction> = loaded_auctions
+        .into_iter()
+        .map(|mut x| {
+            if Utc::now().with_timezone(&Local).timestamp() > x.timestamp {
+                // auction has expired, mark price as final
+                x.is_price_final = true;
+                }
+                x
+            }
+            )
+        .map(|x| (x.url.clone(), x.clone()))
+        .collect();
+    
 
-    return;
+    // return;
     println!("Starting daemon with {} active queries", queries.len());
     loop {
         // TODO: see if we can get rid of clone