'use strict'; /** * GET /api/accuracy (Session 55) — the system's track record. * * Public, cache-only read of the model's track record. Powers the AccuracyBadge * "A-RATED · X% HIT · 30D" pill and the grade-card accuracy line. * * Truth-Everywhere Part 2 (item 7) — sourced from the CLEAN Postgres ledger * aggregate (getAccuracyView: model_value > 0 excludes the degraded * projection-0 rows), NOT the Redis outcome log (which still counts them and * can't be filtered). Redis is a cache; when a cache can't be filtered, read * from truth. NEVER triggers settlement → no API credits spent. */ const express = require('express'); const { createRateLimit } = require('../middleware/rateLimit'); const ledgerService = require('../services/ledgerService'); const router = express.Router(); router.use(createRateLimit({ windowMs: 60_000, max: 60 })); router.get('/', async (req, res) => { try { const acc = await ledgerService.getAccuracyView({}); res.set('Cache-Control', 'public, max-age=300'); return res.json(acc); } catch (err) { console.error('[accuracy]', err.message); return res.status(200).json({ overall: null, sports: {}, min_sample: 20, updated_at: null }); } }); module.exports = router;