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:
martbost
2026-10-23 07:11:37 -05:00
parent 7c96e59db7
commit 1c2ef3780c
15 changed files with 504 additions and 28 deletions
+6 -1
View File
@@ -177,6 +177,11 @@
</div>
<div class="pane" id="pane-campaigns" hidden>
<div class="card">
<div class="card-head"><h3>Login-ad queue</h3><span class="sub" id="lqSub">paid reservations, first paid first served</span></div>
<p class="small muted" style="margin:0 0 8px">Members pay in full when they reserve. The oldest reservation starts by itself within a minute of a slot freeing (a slot ends or is paused). Cancel before start refunds the whole amount as purchased credits.</p>
<div class="tablewrap"><table class="adm-table" id="lqTable"></table></div>
</div>
<div class="card">
<div class="card-head"><h3>All campaigns</h3><span class="sub" id="campSub">newest first</span></div>
<p style="margin:0 0 10px"><input id="campFilter" placeholder="Filter by owner, name, type or status" style="width:100%"></p>
@@ -507,6 +512,6 @@
<script src="/assets/common.js?v=20261018p25"></script>
<script src="/assets/admin-kb.js?v=20261020kb"></script>
<script src="/assets/admin.js?v=20261020m1"></script><script src="/assets/admin-sponsorcheck.js?v=20261022sc"></script>
<script src="/assets/admin.js?v=20261023q"></script><script src="/assets/admin-sponsorcheck.js?v=20261022sc"></script>
</body>
</html>