diff --git a/public/suite-traffic.js b/public/suite-traffic.js index 7ac7d2a..d1fa0f0 100644 --- a/public/suite-traffic.js +++ b/public/suite-traffic.js @@ -175,6 +175,16 @@ var l = byId[c.adId] || {}; var tr = document.createElement('tr'); var served = l.served != null ? l.served : 0; + // The ad network's own counters sometimes drift ABOVE what we bought — + // its remaining has been observed at 3,521 on a 2,500 purchase. The cause + // is inside the ionCube-encoded ad app, so we cannot fix it at source; we + // can stop it rendering as nonsense. Clamp to what the member actually + // bought so the row always reconciles: served + left = bought. Any genuine + // over-delivery is a bonus to them and needs no explanation on this table. + var bought = Number(c.bought != null ? c.bought : c.impressions) || 0; + var rawLeft = l.remaining != null ? Number(l.remaining) : null; + var left = rawLeft == null ? null : Math.max(0, Math.min(rawLeft, bought)); + var servedShown = left == null ? Number(served) : Math.max(0, bought - left); var statusCell = c.stopped ? 'stopped (' + Number(c.refunded || 0).toLocaleString() + ' returned)' : (l.live ? 'running' : 'finished'); @@ -184,8 +194,8 @@ tr.innerHTML = '