huskies: merge 1017
This commit is contained in:
@@ -104,14 +104,13 @@ pub(crate) fn build_status_from_items(
|
||||
.map(|a| (a.story_id.clone(), a))
|
||||
.collect();
|
||||
|
||||
// Read token usage once for all stories to avoid repeated file I/O.
|
||||
let cost_by_story: HashMap<String, f64> = crate::agents::token_usage::read_all(project_root)
|
||||
.unwrap_or_default()
|
||||
.into_iter()
|
||||
.fold(HashMap::new(), |mut map, r| {
|
||||
*map.entry(r.story_id).or_insert(0.0) += r.usage.total_cost_usd;
|
||||
map
|
||||
});
|
||||
// Build a per-story cost map from the in-memory rollup register.
|
||||
// Only completed stories have entries; in-progress stories show no cost.
|
||||
let cost_by_story: HashMap<String, f64> =
|
||||
crate::service::agents::cost_rollup::all_rollups(project_root)
|
||||
.into_iter()
|
||||
.map(|r| (r.story_id, r.total_cost_usd))
|
||||
.collect();
|
||||
|
||||
let config = ProjectConfig::load(project_root).ok();
|
||||
|
||||
|
||||
@@ -181,6 +181,7 @@ fn status_shows_cost_when_token_usage_exists() {
|
||||
usage,
|
||||
);
|
||||
crate::agents::token_usage::append_record(tmp.path(), &record).unwrap();
|
||||
crate::service::agents::cost_rollup::init_from_disk(tmp.path());
|
||||
|
||||
let agents = AgentPool::new_test(3000);
|
||||
let output = build_status_from_items(tmp.path(), &agents, &items);
|
||||
@@ -239,6 +240,7 @@ fn status_aggregates_multiple_records_per_story() {
|
||||
);
|
||||
crate::agents::token_usage::append_record(tmp.path(), &record).unwrap();
|
||||
}
|
||||
crate::service::agents::cost_rollup::init_from_disk(tmp.path());
|
||||
|
||||
let agents = AgentPool::new_test(3000);
|
||||
let output = build_status_from_items(tmp.path(), &agents, &items);
|
||||
|
||||
Reference in New Issue
Block a user