Repository navigation
Commit d270d24
What the fleet costs and what it returns, in the terminal (#240)
`crawlproof dashboard` (also roi, tui) is a live hqtui dashboard over three
feeds that have never been in the same place: the tracker for who arrived, the
ad network for what was delivered, and CoinPay for what the bank actually did.
Five screens — ROI, Traffic, Ads, Money, Spend — refreshing on a timer, plus
--json for the same snapshot without a terminal.
Two rules run through the arithmetic, because breaking either produces a
flattering number that is false:
Self-deal is not revenue. We advertise on our own slots, so ad spend and ad
earnings are one dollar moving between two pockets. They are reported under
Internal and counted as neither cost nor revenue.
Personal money is not fleet cost. The bank feed carries groceries next to
servers, so cost is the business scope only, joined from each ledger row's
account to that account's effective_scope.
Everything is normalised to a monthly rate and prorated onto the traffic
window, because burn is a rate and the traffic side can be asked for an hour
while the bank side only answers in weeks.
Two token-authed reads to feed it:
GET /api/ads/v1/earnings — the model /dashboard/ads/earnings already builds.
Without it a client wanting fleet totals needs one request per campaign, and
the account is past 170 of them.
GET /api/tracker/v1/sites — /stats already names every project, but only
inside the 400 it returns when the caller does not say which. A client should
not have to parse an error message to find the fleet.
loadEarnings now filters ad_campaigns, ad_slots, ad_ledger and ad_payouts by
owner_id explicitly rather than leaning on RLS. For the dashboard that is a
no-op narrowing of what RLS already allows; for the new route, which passes the
service client, it is the security boundary.
The dashboard reports what it cannot know as loudly as what it can: a site that
did not answer is missing rather than zero, a vendor list built from one page of
a longer ledger says so, and a fleet whose visits run 200x its pageviews — or
whose average is really one busy site — says that too, next to the number.
Claude-Session: https://claude.ai/code/session_01HvWJ4336pxTFRdRbvsTQeD
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent ef843df commit d270d24
12 files changed
Lines changed: 2522 additions & 8 deletions
File tree
- app/api
- ads/v1/earnings
- tracker/v1/sites
- cli
- lib
- ads
- dashboard
- tracker
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
0 commit comments