Show recorded figures for closed campaigns, not the wiped counter

My own sweep created this. Deactivating an ad ZEROES `remaining` on the
network, and for banners — where that column counts UP — zero reads as
"served nothing". So every campaign the sweep closed flipped to 0 served /
2,500 left, despite the ledger correctly recording served=2500,
completed=true.

Closed campaigns now read from what we recorded at the time rather than
re-deriving from a counter that no longer holds anything. Live campaigns
still compute from the network, per placement type.

Also removed the em-dash placeholder that blanked LEFT for stopped rows —
there is a real number to show — and made stop()'s error path assume fully
served rather than fully unserved, since guessing high would refund
impressions that had actually been delivered.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-08-30 05:33:55 -05:00
parent 26f2c91684
commit 59bd4bd4ab
2 changed files with 15 additions and 4 deletions
+5 -1
View File
@@ -238,7 +238,11 @@ async function stop(memberId, adId) {
served = r.served;
unserved = r.left;
}
} catch (e) { /* if stats are unavailable, refund nothing rather than guess */ }
} catch (e) {
// Stats unavailable: refund nothing rather than guess. Guessing high would
// hand back impressions that were actually delivered.
served = boughtGuess; unserved = 0;
}
await callNas({ action: 'deactivate', ad_id: Number(adId) });