Commit 56adf87
fix(usage): keep reporting-only rows and rounding out of the credit views
Fifth review round, plus a migration renumber — staging took 0310, so the enum
addition is now 0311.
Unbilled rows leaked into every credit-denominated dimension. They carry a user, a
workspace, a workflow and `source = 'workflow'` like any other row, so a BYOK-only
member appeared in Members at zero credits and their runs inflated the event counts
on Workspaces and Sources. Excluded with `HAVING SUM(cost) > 0` rather than a
`category` predicate: `category` is not in
`usage_log_billing_entity_created_at_cost_idx`, so filtering on it would force a
heap fetch on `member` and `source`, the two dimensions that are index-only and the
reason first paint is cheap. `cost` is in that index, and only an unbilled row can
sum to zero.
Ranking BYOK by tokens last round was half a change: `share` still divided cost by
a total cost of zero, so every provider's bar rendered at the same minimum width
and the ranking was invisible. Share is now measured in whatever the list is ranked
by, derived from the same argument so the two cannot disagree.
Series buckets were each rounded to credits independently, so any day under half a
credit rendered as zero — an organization spending a fraction of a credit a day drew
a flat chart beneath a positive headline. They now go through one `apportionCredits`
pass, the same rule the breakdown rows use.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 8a0b677 commit 56adf87
4 files changed
Lines changed: 72 additions & 15 deletions
File tree
- apps/sim/lib/billing
- application/organization-usage
- core
Lines changed: 24 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
76 | 97 | | |
77 | 98 | | |
78 | 99 | | |
| |||
82 | 103 | | |
83 | 104 | | |
84 | 105 | | |
85 | | - | |
86 | | - | |
| 106 | + | |
87 | 107 | | |
88 | | - | |
| 108 | + | |
89 | 109 | | |
90 | 110 | | |
91 | 111 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
155 | 169 | | |
156 | 170 | | |
157 | 171 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
434 | 434 | | |
435 | 435 | | |
436 | 436 | | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
437 | 449 | | |
438 | 450 | | |
439 | 451 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
469 | 469 | | |
470 | 470 | | |
471 | 471 | | |
472 | | - | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
473 | 481 | | |
474 | 482 | | |
475 | | - | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
476 | 487 | | |
477 | 488 | | |
478 | 489 | | |
| |||
0 commit comments