Prepaid login-ad slot queue (Marty, 2026-10-23: "they need to pay for the slot now to get a place in line")
When all member login slots are taken the Ads screen offers "Reserve the next slot" instead of a dead button. Same price and checks as a slot (purchased credits only), paid at reserve time; the campaign is 'queued' with queuedAt, never serves and has no 30-day clock. First paid, first served: the member sees their place and an estimated start (Central time, labelled an estimate) built from the live slots' end dates and the line ahead. A freed slot (ended, paused, or found by the new 1-minute tick) goes to the oldest reservation: starts now, expires now + 30 days, never more than loginSlotsMax live. Idempotent across the deploy overlap: JSON mode takes a lock file and records every promotion/cancel in DATA_DIR/login-queue.json, re-read before any change; MySQL mode uses guarded UPDATEs (status + live count in one statement). Owner gets an on-site notice and an email (unsubscribes respected). A paused slot resumes only when live + queued < max. Cancel before start = full refund (credited back as purchased credits; any unburned accrual released). Edits while queued are free and keep the free correction. Admin: Login-ad queue card with cancel + refund, plus the Member content action. New credit activity log (credit-log.json / credit_log table): reserved (queue #N), bought, started, refunds, shown on the Ads screen. Audit skips queued/cancelled login rows. Chatbot CANNED + FACTS updated (6 slots, paid queue, full refund before start). Tags bumped: ads-screen.js, admin.js, my.js 20261023q. Tests: qa/loginqueue.test.cjs (two app copies promoting at once) + qa/loginqueue.e2e.mjs; bash qa/run.sh loginqueue. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -137,6 +137,19 @@ async function bootstrap() {
|
||||
await alterSafe("ALTER TABLE campaigns ADD COLUMN day_key CHAR(10) NULL");
|
||||
await alterSafe('ALTER TABLE campaigns ADD COLUMN edits INT NOT NULL DEFAULT 0'); // member edits so far (the first is free), 2026-10-18
|
||||
await alterSafe('ALTER TABLE campaigns ADD COLUMN edit_log MEDIUMTEXT NULL'); // JSON [{ts, by, fields, from, to, fee, paidFrom}], last 50
|
||||
// prepaid login-slot queue (Marty, 2026-10-23): paid at reserve time, status 'queued' until a slot frees
|
||||
await alterSafe('ALTER TABLE campaigns ADD COLUMN queued_at BIGINT NULL'); // when the place in line was paid for (first paid, first served)
|
||||
await alterSafe('ALTER TABLE campaigns ADD COLUMN promoted_at BIGINT NULL'); // when it left the line and its 30 days started
|
||||
await alterSafe('ALTER TABLE campaigns ADD COLUMN refunded INT NOT NULL DEFAULT 0'); // credits handed back on a cancel before start
|
||||
await q(`CREATE TABLE IF NOT EXISTS credit_log (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
email VARCHAR(190) NOT NULL,
|
||||
ts BIGINT NOT NULL,
|
||||
delta INT NOT NULL,
|
||||
reason VARCHAR(160) NOT NULL,
|
||||
campaign_id INT NULL,
|
||||
INDEX (email, ts)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4`);
|
||||
// linked positions: extra wallets owned by one email account (Qualified Start).
|
||||
// Each is its own on-chain member sponsored by the account's main member.
|
||||
await q(`CREATE TABLE IF NOT EXISTS positions (
|
||||
|
||||
Reference in New Issue
Block a user