refactor: remove dead code, replace sum_matching tests with evaluate()

Removes unused methods (sum_matching, get_mut, item_by_name, item_index,
top_level_groups, is_group_collapsed, show_item) and unused constants
(LABEL_THRESHOLD, MIN_COL_WIDTH).

The sum_matching tests in model.rs were bypassing the formula evaluator
entirely. Replaced them with equivalent tests that call evaluate() against
the existing Total = SUM(Revenue) formula, exercising the real aggregation
code path.

Also fixes a compile error in view.rs prop_tests where View/Axis imports
and a doc comment were incorrectly commented out.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Edward Langley
2026-03-30 22:56:04 -07:00
parent 15f7fbe799
commit a1b17dc9af
7 changed files with 102 additions and 140 deletions

View File

@ -113,10 +113,6 @@ impl DataStore {
self.cells.get(key)
}
pub fn get_mut(&mut self, key: &CellKey) -> Option<&mut CellValue> {
self.cells.get_mut(key)
}
pub fn cells(&self) -> &HashMap<CellKey, CellValue> {
&self.cells
}
@ -125,14 +121,6 @@ impl DataStore {
self.cells.remove(key);
}
/// Sum all cells matching partial coordinates
pub fn sum_matching(&self, partial: &[(String, String)]) -> f64 {
self.cells.iter()
.filter(|(key, _)| key.matches_partial(partial))
.filter_map(|(_, v)| v.as_f64())
.sum()
}
/// All cells where partial coords match
pub fn matching_cells(&self, partial: &[(String, String)]) -> Vec<(&CellKey, &CellValue)> {
self.cells.iter()
@ -274,24 +262,6 @@ mod data_store {
assert!(store.cells().is_empty());
}
#[test]
fn sum_matching_sums_across_dimension() {
let mut store = DataStore::new();
store.set(key(&[("Measure", "Revenue"), ("Region", "East")]), CellValue::Number(100.0));
store.set(key(&[("Measure", "Revenue"), ("Region", "West")]), CellValue::Number(200.0));
store.set(key(&[("Measure", "Cost"), ("Region", "East")]), CellValue::Number(50.0));
let partial = vec![("Measure".to_string(), "Revenue".to_string())];
assert_eq!(store.sum_matching(&partial), 300.0);
}
#[test]
fn sum_matching_empty_partial_sums_everything() {
let mut store = DataStore::new();
store.set(key(&[("Region", "East")]), CellValue::Number(10.0));
store.set(key(&[("Region", "West")]), CellValue::Number(20.0));
assert_eq!(store.sum_matching(&[]), 30.0);
}
#[test]
fn matching_cells_returns_correct_subset() {
let mut store = DataStore::new();
@ -306,13 +276,6 @@ mod data_store {
assert!(values.contains(&200.0));
}
#[test]
fn text_values_excluded_from_sum() {
let mut store = DataStore::new();
store.set(key(&[("Cat", "A")]), CellValue::Number(10.0));
store.set(key(&[("Cat", "B")]), CellValue::Text("hello".into()));
assert_eq!(store.sum_matching(&[]), 10.0);
}
}
#[cfg(test)]