The workspace cost alert compares only days that carry their value, not the days before it was kept
1 file+5−10/1 viewed
| 1129 | 1129 | // Against what its usage was priced at, not the cash it | |
| 1130 | 1130 | // paid: a trial or a gift paying for usage is not a price | |
| 1131 | 1131 | // below cost. | |
| 1132 | + | // Days from before value_micros was kept have none: only days | |
| 1133 | + | // since the first one that does are compared. | |
| 1132 | 1134 | "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", | |
| 1134 | 1138 | crate::sales::INTERNAL_SQL | |
| 1135 | 1139 | )) | |
| 1136 | 1140 | .bind(&[day_before(until, ANOMALY_DAYS - 1).into(), until.into()])? |