Commit

The workspace cost alert compares only days that carry their value, not the days before it was kept

syntaqxcommitted Parent107eb49Browse files
1 file+5−10/1 viewed
+5−1
11291129 // Against what its usage was priced at, not the cash it
11301130 // paid: a trial or a gift paying for usage is not a price
11311131 // below cost.
1132+ // Days from before value_micros was kept have none: only days
1133+ // since the first one that does are compared.
11321134 "SELECT workspace, SUM(cost_micros) AS cost, SUM(value_micros) AS revenue FROM workspace_costs
1133− WHERE day >= ?1 AND day <= ?2 AND workspace NOT IN ({}) GROUP BY workspace",
1135+ WHERE day >= ?1 AND day <= ?2 AND workspace NOT IN ({})
1136+ AND day >= (SELECT MIN(day) FROM workspace_costs WHERE value_micros > 0)
1137+ GROUP BY workspace",
11341138 crate::sales::INTERNAL_SQL
11351139 ))
11361140 .bind(&[day_before(until, ANOMALY_DAYS - 1).into(), until.into()])?