Stack POL data in MySQL (Marty 2026-11-16: payout totals wiped on every deploy)

The indexer snapshot (was /tmp/stack-index.json) and the chatbot KB (was memory)
are now MySQL documents via docstore.js (DOCSTORE_URL, Coolify stackpol-mysql),
loaded before the server listens so a deploy shows the last totals at once.
Snapshot split into stack-index.json + stack-index-at.json so a push with no new
payouts rewrites only the tiny doc (docstore skips unchanged bodies). Ingest API
unchanged. Tested on core: restart keeps totals, /programs, /earn, member pages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-16 04:46:28 -06:00
parent b6e020e025
commit 96d6281e3e
8 changed files with 383 additions and 14 deletions
+4 -3
View File
@@ -1,7 +1,8 @@
// Stack POL's site assistant (Marty 2026-11-15): what it knows. The engine is chatcore.js (the same on every rebuilt site);
// retrieval also covers the other network sites through the hub (netkb.js), this site's entries first.
// Stack POL has no database and no data volume: its own entries live in memory (seeded from this file at boot), and the
// OpenRouter key comes from the OPENROUTER_API_KEY env (a Coolify secret). No admin knowledge-base editing here.
// Storage (2026-11-16): kb.json and netkb-cache.json are MySQL documents through docstore.js (DOCSTORE_URL, stackpol-mysql), so
// the entries and the cached network set survive a deploy. The OpenRouter key comes from the OPENROUTER_API_KEY env (a Coolify
// secret). No admin knowledge-base editing here.
//
// Every fact below was checked against this repo on KNOWLEDGE_DATE: server.js (the on-page FAQ, the pages, /api/totals, member
// stacks only when switched on), programs.js (the programs and their kinds), README.md (the indexer refreshes every 5 minutes;
@@ -66,7 +67,7 @@ const FACTS = () => [
const SITE = {
id: 'stackpol', hubSite: 'stackpol', netId: 'stackpol', name: 'Stack POL', url: URL_, supportUrl: SUPPORT, knowledgeDate: KNOWLEDGE_DATE,
dataDir: null, canned: CANNED, faq: FAQ, facts: FACTS,
dataDir: process.env.DATA_DIR || require('path').join(__dirname, 'data'), canned: CANNED, faq: FAQ, facts: FACTS,
intro: 'You are the assistant on Stack POL (' + URL_ + '), the network\'s payout tracker: it adds up every POL payout across the network\'s sites and games, each one checkable on Polygon. Most questions about how to earn belong to a specific program: answer from that program\'s entries and link to it.',
quickTopics: ['What is Stack POL?', 'How do I get my own page?', 'What is ViralAdBlitz?', 'How does Downline Banners pay?']
};