Campaigns: optional daily cap on banner/text paces spend on-site and hands Network Ad Space one day's allowance at a time
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -58,7 +58,8 @@ async function pushCampaign(c, opts = {}) {
|
||||
const kind = nasKind(c.type);
|
||||
if (!kind) return { skipped: 'type' };
|
||||
const budgetLeft = c.budget - (c.spent || 0);
|
||||
const assigned = Math.max(1, Math.floor(budgetLeft * impressionsPerCredit(c.type)));
|
||||
const window = c.dailyCap ? Math.min(c.dailyCap, budgetLeft) : budgetLeft; // capped campaigns start with one day's allowance
|
||||
const assigned = Math.max(1, Math.floor(window * impressionsPerCredit(c.type)));
|
||||
const token = 'iap_' + crypto.randomBytes(8).toString('hex'); // manage token = Username
|
||||
const now = new Date();
|
||||
const days = Number(opts.days || 30);
|
||||
|
||||
Reference in New Issue
Block a user