refactor: define hydrogen BI metric semantics

This commit is contained in:
kkfluous
2026-08-07 14:33:38 +08:00
parent b2044109e3
commit d53257c65c
4 changed files with 145 additions and 14 deletions
+11
View File
@@ -21,7 +21,18 @@ test('lists mileage metrics without exposing the catalog array', () => {
assert.ok(metrics.every(metric => metric.domain === 'mileage'));
});
test('publishes hydrogen cost, revenue, and gross profit as separate metrics', () => {
const metrics = listMetricDefinitions('hydrogen');
const byId = new Map(metrics.map(metric => [metric.id, metric]));
assert.ok(metrics.length >= 8);
assert.equal(byId.get('hydrogen.refuel_cost')?.formula, "SUM(cost_total) WHERE del_flag = '0'");
assert.equal(byId.get('hydrogen.customer_revenue')?.formula, "SUM(fee_total) WHERE del_flag = '0'");
assert.equal(byId.get('hydrogen.customer_order_gross_profit')?.aggregation, 'derived');
});
test('validates only published metric domains', () => {
assert.equal(isMetricDomain('mileage'), true);
assert.equal(isMetricDomain('hydrogen'), true);
assert.equal(isMetricDomain('unknown'), false);
});