Skip to content

Commit 5dff79f

Browse files
committed
Fix: use config.update_interval for rotation, add is_fallback flag to PriceData
1 parent edf1fe0 commit 5dff79f

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/bot.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,8 +873,9 @@ async fn price_update_loop(
873873
};
874874

875875
// Format the custom status with rotation
876+
let update_interval_secs = config.update_interval.as_secs().max(1);
876877
let update_count = match get_current_timestamp() {
877-
Ok(time) => (time / 12) % 4,
878+
Ok(time) => (time / update_interval_secs) % 4,
878879
Err(_) => 0,
879880
};
880881

src/price_service.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ pub struct PriceData {
1717
pub premium: Option<f64>,
1818
pub premium_percent: Option<f64>,
1919
pub source: Option<String>,
20+
#[serde(default)]
21+
pub is_fallback: bool,
2022
}
2123

2224
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)]
@@ -263,6 +265,7 @@ async fn fetch_yahoo_price(
263265
premium: None,
264266
premium_percent: None,
265267
source: Some("yahoo".to_string()),
268+
is_fallback: false,
266269
});
267270
}
268271
}
@@ -303,6 +306,7 @@ async fn fetch_all_prices() -> Result<PricesFile, Box<dyn std::error::Error + Se
303306
premium: None,
304307
premium_percent: None,
305308
source: None,
309+
is_fallback: false,
306310
},
307311
);
308312
info!("Fetched {} price: ${:.6}", crypto, price);
@@ -325,6 +329,7 @@ async fn fetch_all_prices() -> Result<PricesFile, Box<dyn std::error::Error + Se
325329
premium: None,
326330
premium_percent: None,
327331
source: None,
332+
is_fallback: true,
328333
},
329334
);
330335
}
@@ -408,6 +413,7 @@ pub async fn fetch_shanghai_silver_price(
408413
premium: Some(premium),
409414
premium_percent: Some(premium_percent),
410415
source: Some("shanghaisilver_spot".to_string()),
416+
is_fallback: false,
411417
})
412418
}
413419

0 commit comments

Comments
 (0)