A comped workspace's Usage shows what its runs used at cost, not $0.00 spent and a $0.000 average
1 file+7−40/1 viewed
| 191 | 191 | const days = Math.max(1, Math.ceil((Date.now() - new Date(since).getTime()) / 86_400_000)); | |
| 192 | 192 | // While g1t is free nothing is charged, so usage is measured at cost | |
| 193 | 193 | // and credit is not drawn down. | |
| 194 | − | const total = usage.free ? usage.usedMicros : usage.spentMicros; | |
| 195 | − | const perDay = usage.free ? 0 : total / days; | |
| 194 | + | // Free or comped, nothing is charged: what the runs used, at cost, is | |
| 195 | + | // what there is to show. | |
| 196 | + | const atCost = usage.free || comped; | |
| 197 | + | const total = atCost ? usage.usedMicros : usage.spentMicros; | |
| 198 | + | const perDay = atCost ? 0 : total / days; | |
| 196 | 199 | const runway = perDay > 0 ? Math.floor(account.balanceMicros / perDay) : null; | |
| 197 | 200 | return ( | |
| 198 | 201 | <div className="space-y-8"> | |
| 214 | 217 | </div> | |
| 215 | 218 | ||
| 216 | 219 | <div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4"> | |
| 217 | − | {usage.free ? ( | |
| 220 | + | {atCost ? ( | |
| 218 | 221 | <Stat | |
| 219 | 222 | label="Used" | |
| 220 | 223 | value={dollars(total)} | |
| 221 | − | note="At cost. Nothing is charged while g1t is being built out." | |
| 224 | + | note={comped ? "At cost. The workspace is comped: nothing is charged." : "At cost. Nothing is charged while g1t is being built out."} | |
| 222 | 225 | /> | |
| 223 | 226 | ) : ( | |
| 224 | 227 | <Stat |