Commit

A comped workspace's Usage shows what its runs used at cost, not $0.00 spent and a $0.000 average

syntaqxcommitted Parent77a168aBrowse files
1 file+7−40/1 viewed
+7−4
191191 const days = Math.max(1, Math.ceil((Date.now() - new Date(since).getTime()) / 86_400_000));
192192 // While g1t is free nothing is charged, so usage is measured at cost
193193 // 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;
196199 const runway = perDay > 0 ? Math.floor(account.balanceMicros / perDay) : null;
197200 return (
198201 <div className="space-y-8">
214217 </div>
215218
216219 <div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
217− {usage.free ? (
220+ {atCost ? (
218221 <Stat
219222 label="Used"
220223 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."}
222225 />
223226 ) : (
224227 <Stat