// ── SQL for Economics (PLAN_REDESIGNS §11.2.2) ──────────────────────────── // // What each server's last hello said about Economics. The balances themselves // are rows of `rust_player_wipe_stats` and are written by ingest through // `events.db.js`; this file only reads the report the plugin makes about the // plugin. const core = require('../../core') const STATE = 'rust_server_state' /** * Every server's report: `{ serverId, wipeId, economics }`, with `economics` * as the driver hands JSON_EXTRACT back — text, or null for a server whose * plugin never said (no state yet, or a plugin before protocol 14). */ async function reports() { return core.query( `SELECT server_id AS serverId, wipe_id AS wipeId, JSON_EXTRACT(raw, '$.integrations.economics') AS economics FROM ${STATE}`, ) } async function reportFor(serverId) { const rows = await core.query( `SELECT server_id AS serverId, wipe_id AS wipeId, JSON_EXTRACT(raw, '$.integrations.economics') AS economics FROM ${STATE} WHERE server_id = ?`, [serverId], ) return rows[0] || null } module.exports = { reports, reportFor }