Traffic Desk UI: trust the bridge's served figure — remove the count-up banner branch here too

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-02 06:22:16 -05:00
parent 8ea371dd09
commit 726bc24e09
+17 -18
View File
@@ -174,29 +174,28 @@
campaigns.slice().reverse().forEach(function (c) { campaigns.slice().reverse().forEach(function (c) {
var l = byId[c.adId] || {}; var l = byId[c.adId] || {};
var tr = document.createElement('tr'); var tr = document.createElement('tr');
var served = l.served != null ? l.served : 0; // The bridge computes served for us (assigned − remaining; `remaining`
// The ad network's own counters sometimes drift ABOVE what we bought — // counts DOWN for BOTH ad kinds — the old "banners count up" theory made
// its remaining has been observed at 3,521 on a 2,500 purchase. The cause // every fresh banner render as delivered-in-full the moment it launched).
// is inside the ionCube-encoded ad app, so we cannot fix it at source; we // The network's counters also drift ABOVE what we bought (3,521 observed
// can stop it rendering as nonsense. Clamp to what the member actually // on a 2,500 purchase; cause is inside the ionCube-encoded ad app), so
// bought so the row always reconciles: served + left = bought. Any genuine // clamp to what the member bought: served + left = bought, always. Any
// over-delivery is a bonus to them and needs no explanation on this table. // genuine over-delivery is a bonus to them and needs no explanation here.
// The network counts `remaining` DOWN for text ads and UP for banners —
// measured, not documented. Reading both the same way showed every banner
// as 0 served while it was quietly delivering thousands.
var bought = Number(c.bought != null ? c.bought : c.impressions) || 0; var bought = Number(c.bought != null ? c.bought : c.impressions) || 0;
var rawRem = l.remaining != null ? Number(l.remaining) : null;
var servedShown, left; var servedShown, left;
if (c.completed || c.stopped) { if (c.completed || c.stopped) {
// Once a campaign is closed, trust what we recorded at the time. // Once a campaign is closed, trust what we recorded at the time —
// Deactivating an ad ZEROES `remaining` on the network — and for a // deactivating an ad ZEROES `remaining` on the network, so re-deriving
// banner, where that column counts UP, zero reads as "served nothing". // from live counters would misreport a finished campaign.
// Re-deriving here would wipe a finished campaign back to 0 served.
servedShown = Number(c.served != null ? c.served : bought) || 0; servedShown = Number(c.served != null ? c.served : bought) || 0;
left = Math.max(0, bought - servedShown); left = Math.max(0, bought - servedShown);
} else if (rawRem == null) { servedShown = Number(served) || 0; left = null; } } else if (l.served != null) {
else if (c.kind === 'text') { left = Math.max(0, Math.min(rawRem, bought)); servedShown = bought - left; } servedShown = Math.max(0, Math.min(Number(l.served) || 0, bought));
else { servedShown = Math.max(0, Math.min(rawRem, bought)); left = bought - servedShown; } left = bought - servedShown;
} else if (l.remaining != null) {
left = Math.max(0, Math.min(Number(l.remaining) || 0, bought));
servedShown = bought - left;
} else { servedShown = 0; left = null; }
// "running" with 0 left reads as broken. It is not: banners have no cap on // "running" with 0 left reads as broken. It is not: banners have no cap on
// this network — the counter runs past the purchase and the ad keeps // this network — the counter runs past the purchase and the ad keeps
// serving until its expiry, so a fully-delivered banner is genuinely // serving until its expiry, so a fully-delivered banner is genuinely