Engine Room (Fuel Your Offers stage 4, Marty approved 2026-10-24): a new Members tab (engineNav, pane-engine) on InstantAdPay, shown only while refuelStreak is on, unlocked by the first counted refuel and greyed with one move "Refuel to start your engine" before. engine.js (the same file ships in LinkSpin): facts() gathers one site's member facts (credits free + in campaigns, recent campaigns, clicks this week and last week from click_sources via coach.clicksSince, free login slots; on LinkSpin also goals this month from the conversion pixel counted from the Central-time 1st, and the Banner Spin / spin link / page / testing parts), build() turns both sites' facts + the streak into three plain dials (fuel left vs this cycle's refuel credits incl. bonus with days left at the recent burn; clicks this week against last week with clicks per 1,000 credits; goals this month vs a member-set goal stored with the streak, refuel.setGoal), the streak panel, warning lights (ads at 80%, ads out, refuel day coming, login slot open), six part lights (fuel, banner spin, spin link, page, testing, conversion tracking: green / amber / grey with setup links) and one next move from simple ordered rules (refuel window, relaunch, Pit Stop top-up, top up the winner, tracking, Banner Spin, test A/B, cut the loser, keep running). LinkSpin facts arrive through signed /api/partner/engine (cached a minute; LinkSpin down = unknown, never zero); InstantAdPay answers the same call for LinkSpin's panel with its facts + the streak. Member /api/my/engine, /api/my/engine/goal; partner op refuel/goal. engine-room.js (same file both sites): plain SVG dials with aria labels, works at 390 px, colour only for warnings. Chatbot CANNED + FACTS cover the Engine Room. my.js?v=20261024er (PANES + engine), engine-room.js?v=20261024er. qa/refuel-engine.test.cjs 10 checks (switch, locked, each dial, lights, parts, next-move order, facts on stubbed LinkSpin incl. Central month start, goal storage).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-24 05:55:02 -05:00
parent 50337bfbbc
commit 15f5374fac
9 changed files with 346 additions and 10 deletions
+9 -3
View File
@@ -369,7 +369,7 @@ async function view(email, now) {
const curRate = cy ? (cy.both ? rateBoth(cy.n) : rateSingle(cy.n)) : 0;
const windowOpen = !rec.active || !cy || today >= rec.opensDay;
const freeOk = !rec.freeMissDay || diffDays(rec.freeMissDay, today) >= FREE_MISS_DAYS;
const siteState = s => cy && cy.sites[s] ? { refueled: true, pct: cy.sites[s].pct, bonus: cy.sites[s].bonus, day: cy.sites[s].day, dayLabel: label(cy.sites[s].day) } : { refueled: false };
const siteState = s => cy && cy.sites[s] ? { refueled: true, credits: cy.sites[s].credits, pct: cy.sites[s].pct, bonus: cy.sites[s].bonus, day: cy.sites[s].day, dayLabel: label(cy.sites[s].day) } : { refueled: false };
return {
on: true, started: !!rec.firstDay, engineUnlocked: !!rec.firstDay, active: rec.active, streak: k, best: rec.best || 0,
firstDay: rec.firstDay, lastDay: rec.lastDay, refuelDay: rec.dueDay, refuelDayLabel: label(rec.dueDay), opensDay: rec.opensDay, opensLabel: label(rec.opensDay),
@@ -378,7 +378,7 @@ async function view(email, now) {
next: windowOpen ? { month: next, single: rateSingle(next), both: rateBoth(next) } : { month: cy.n, secondEngine: rateBoth(cy.n) },
pitStop: cy && !windowOpen ? { pct: curRate / 2, iap: !cy.pit.iap && !!cy.sites.iap, linkspin: !cy.pit.linkspin && !!cy.sites.linkspin, usedIap: !!cy.pit.iap, usedLinkspin: !!cy.pit.linkspin } : null,
freeMiss: { available: freeOk, usedDay: rec.freeMissDay }, misses: rec.misses.slice(0, 6), badges: Object.keys(rec.badges || {}),
kits: rec.kits || {},
kits: rec.kits || {}, goal: rec.engineGoal || null,
minUsd: { iap: c.minIap / 100, linkspin: c.minLs / 100 }, ladder: { single: SINGLE, both: BOTH }, refuelDay1: c.dayPromo ? c.dayPct : 0,
};
}
@@ -392,6 +392,12 @@ async function streakLine(email) {
else t = 'Refuel streak: month ' + v.streak + ', next refuel day ' + v.refuelDayLabel + ' (Central time).' + (v.pitStop && (v.pitStop.iap || v.pitStop.linkspin) ? ' A top-up before then earns a Pit Stop bonus of +' + v.pitStop.pct + '% (once per site this cycle).' : '');
return { text: t, html: '<b>Refuel streak:</b> ' + esc(t.replace(/^Refuel streak: /, '')) };
}
// the member's own monthly goal for the Engine Room's goals dial (conversions from the pixel); 0 clears it
async function setGoal(email, goal) {
if (!cfg().on) return { error: 'The Engine Room is not switched on.' };
email = String(email || '').toLowerCase(); const g = Math.max(0, Math.min(100000, Math.round(Number(goal) || 0)));
return lock(email, async () => { const rec = (await getRec(email)) || blank(email); rec.engineGoal = g || null; await putRec(rec); return { ok: true, goal: rec.engineGoal }; });
}
function badgesOf(email) { return getRec(String(email || '').toLowerCase()).then(r => (r && cfg().on) ? Object.keys(r.badges || {}) : []).catch(() => []); }
// ---- admin ------------------------------------------------------------------------------------------
@@ -404,5 +410,5 @@ async function stats() {
recent: rows.slice(0, 40).map(r => ({ ref: r.ref, site: r.site, email: r.email, kind: r.kind === 'grant' ? r.payload.kind : 'reminder:' + r.payload.remind, credits: r.payload.credits || 0, status: r.status, at: r.created })) };
}
module.exports = { init, cfg, record, roundup, weekOf, feedLine, onIapPurchase, decide, settle, blank, view, streakLine, badgesOf, outbox, ack, drainLocal, tick, stats, reminderCopy,
module.exports = { setGoal, init, cfg, record, roundup, weekOf, feedLine, onIapPurchase, decide, settle, blank, view, streakLine, badgesOf, outbox, ack, drainLocal, tick, stats, reminderCopy,
_days: { ctDay, addDays, diffDays, label, ctHour }, SINGLE, BOTH };