Skip to content

Commit

Permalink
Merge pull request #4 from kevinxft/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinxft authored Dec 13, 2024
2 parents d186253 + ca0a4f8 commit 7de9bd3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
Map::new()
};

// 检查是否需要清空历史数据
let should_clear = history.iter().any(|(_, value)| {
if let Some(prev_remaining) = value["remaining_amount"]
.as_str()
.and_then(|s| s.parse::<f64>().ok())
{
remaining > prev_remaining
} else {
false
}
});

// 如果需要清空历史,创建新的空 Map
if should_clear {
history = Map::new();
println!("检测到余额增加,已清空历史数据");
}

// 添加新的数据
history.insert(today, data);

Expand Down

0 comments on commit 7de9bd3

Please sign in to comment.