Compare changes
Choose two branches to see what one has that the other does not, then open a pull request for it.
1 commit
2 files+19−180/2 viewed
| 6 | 6 | ||
| 7 | 7 | /** | |
| 8 | 8 | * Dollars, to the cent; amounts under a dollar keep up to four places, so | |
| 9 | − | * a run that cost a fraction of a cent does not read as nothing. | |
| 9 | + | * a run that cost a fraction of a cent does not read as nothing. With | |
| 10 | + | * `cents`, always to the cent: for statements, where figures sit in columns. | |
| 10 | 11 | */ | |
| 11 | − | export function usd(micros: number | null | undefined, { signed = false }: { signed?: boolean } = {}): string { | |
| 12 | + | export function usd(micros: number | null | undefined, { signed = false, cents = false }: { signed?: boolean; cents?: boolean } = {}): string { | |
| 12 | 13 | if (micros == null) return "—"; | |
| 13 | 14 | const dollars = micros / MICROS_PER_DOLLAR; | |
| 14 | − | const text = (Math.abs(dollars) < 1 ? SMALL : WHOLE).format(Math.abs(dollars)); | |
| 15 | + | const text = (Math.abs(dollars) < 1 && !cents ? SMALL : WHOLE).format(Math.abs(dollars)); | |
| 15 | 16 | if (dollars < 0) return `−${text}`; | |
| 16 | 17 | return signed && dollars > 0 ? `+${text}` : text; | |
| 17 | 18 | } |
| 665 | 665 | title: "Usage sold", | |
| 666 | 666 | note: | |
| 667 | 667 | included > 0 | |
| 668 | − | ? `What workspaces paid for usage (${usd(o.usageMicros)}) and their plan's included usage (${usd(included)}), against what it cost` | |
| 668 | + | ? `What workspaces paid for usage (${usd(o.usageMicros, { cents: true })}) and their plan's included usage (${usd(included, { cents: true })}), against what it cost` | |
| 669 | 669 | : "What workspaces paid for usage, against what that usage cost", | |
| 670 | 670 | in: usageIn, | |
| 671 | 671 | cost: usageCost, | |
| 676 | 676 | title: "Running g1t", | |
| 677 | 677 | note: | |
| 678 | 678 | included > 0 | |
| 679 | − | ? `Plans (${usd(o.plansMicros)}) less the included usage they paid for, against Workers, D1, KV, Queues and the rest` | |
| 679 | + | ? `Plans (${usd(o.plansMicros, { cents: true })}) less the included usage they paid for, against Workers, D1, KV, Queues and the rest` | |
| 680 | 680 | : "Plans, against Workers, D1, KV, Queues and the rest of the platform", | |
| 681 | 681 | in: o.plansMicros - included, | |
| 682 | 682 | cost: running, | |
| 696 | 696 | : []), | |
| 697 | 697 | { | |
| 698 | 698 | title: "Given away", | |
| 699 | − | note: givenParts.length > 0 ? givenParts.map(([why, micros]) => `${why} ${usd(micros)}`).join(" · ") : "Nothing this range", | |
| 699 | + | note: givenParts.length > 0 ? givenParts.map(([why, micros]) => `${why} ${usd(micros, { cents: true })}`).join(" · ") : "Nothing this range", | |
| 700 | 700 | in: null, | |
| 701 | 701 | cost: given, | |
| 702 | 702 | result: null, | |
| 710 | 710 | <Stat | |
| 711 | 711 | label="Margin on usage sold" | |
| 712 | 712 | value={percentLabel(usagePercent)} | |
| 713 | − | hint={`${usd(usageIn)} paid for usage that cost ${usd(usageCost)}`} | |
| 713 | + | hint={`${usd(usageIn, { cents: true })} paid for usage that cost ${usd(usageCost, { cents: true })}`} | |
| 714 | 714 | tone={marginTone(usagePercent, floor)} | |
| 715 | 715 | /> | |
| 716 | 716 | <Stat | |
| 717 | 717 | label="Given away on purpose" | |
| 718 | − | value={usd(given)} | |
| 719 | − | hint={givenParts.length > 0 ? givenParts.map(([why, micros]) => `${usd(micros)} ${why}`).join(", ") : "Nothing given this range"} | |
| 718 | + | value={usd(given, { cents: true })} | |
| 719 | + | hint={givenParts.length > 0 ? givenParts.map(([why, micros]) => `${usd(micros, { cents: true })} ${why}`).join(", ") : "Nothing given this range"} | |
| 720 | 720 | /> | |
| 721 | 721 | <Stat | |
| 722 | 722 | label="Who g1t paid" | |
| 723 | − | value={usd(o.costMicros)} | |
| 724 | − | hint={`Cloudflare ${usd(o.cloudflareCostMicros ?? o.costMicros - (o.modelsCostMicros ?? 0))}, model providers ${usd(o.modelsCostMicros ?? 0)}`} | |
| 723 | + | value={usd(o.costMicros, { cents: true })} | |
| 724 | + | hint={`Cloudflare ${usd(o.cloudflareCostMicros ?? o.costMicros - (o.modelsCostMicros ?? 0), { cents: true })}, model providers ${usd(o.modelsCostMicros ?? 0, { cents: true })}`} | |
| 725 | 725 | /> | |
| 726 | 726 | <Stat | |
| 727 | 727 | label="Proposals waiting" | |
| 749 | 749 | <span className="text-fg">{row.title}</span> | |
| 750 | 750 | <span className="block text-xs text-faint">{row.note}</span> | |
| 751 | 751 | </td> | |
| 752 | − | <td className="tabular px-4 py-2.5 text-right">{row.in == null ? <span className="text-faint">—</span> : usd(row.in)}</td> | |
| 753 | − | <td className="tabular px-4 py-2.5 text-right">{usd(row.cost)}</td> | |
| 752 | + | <td className="tabular px-4 py-2.5 text-right">{row.in == null ? <span className="text-faint">—</span> : usd(row.in, { cents: true })}</td> | |
| 753 | + | <td className="tabular px-4 py-2.5 text-right">{usd(row.cost, { cents: true })}</td> | |
| 754 | 754 | <td className={`tabular px-4 py-2.5 text-right sm:pr-5 ${resultClass(row.tone)}`}> | |
| 755 | − | {row.result == null ? "a budget" : usd(row.result, { signed: true })} | |
| 755 | + | {row.result == null ? "a budget" : usd(row.result, { signed: true, cents: true })} | |
| 756 | 756 | </td> | |
| 757 | 757 | </tr> | |
| 758 | 758 | ))} | |
| 760 | 760 | <td className="px-4 py-2.5 sm:px-5"> | |
| 761 | 761 | <span className="font-medium text-fg">All in</span> | |
| 762 | 762 | <span className="block text-xs text-faint"> | |
| 763 | − | {given > 0 ? `${usd(given)} of the cost was given away on purpose; without it, ${usd(net + given, { signed: true })}` : "Everything above"} | |
| 763 | + | {given > 0 ? `${usd(given, { cents: true })} of the cost was given away on purpose; without it, ${usd(net + given, { signed: true, cents: true })}` : "Everything above"} | |
| 764 | 764 | </span> | |
| 765 | 765 | </td> | |
| 766 | − | <td className="tabular px-4 py-2.5 text-right font-medium">{usd(moneyIn)}</td> | |
| 767 | − | <td className="tabular px-4 py-2.5 text-right font-medium">{usd(spent)}</td> | |
| 768 | − | <td className="tabular px-4 py-2.5 text-right font-medium text-fg sm:pr-5">{usd(net, { signed: true })}</td> | |
| 766 | + | <td className="tabular px-4 py-2.5 text-right font-medium">{usd(moneyIn, { cents: true })}</td> | |
| 767 | + | <td className="tabular px-4 py-2.5 text-right font-medium">{usd(spent, { cents: true })}</td> | |
| 768 | + | <td className="tabular px-4 py-2.5 text-right font-medium text-fg sm:pr-5">{usd(net, { signed: true, cents: true })}</td> | |
| 769 | 769 | </tr> | |
| 770 | 770 | </tbody> | |
| 771 | 771 | </table> |