feat: add has_notes and notes_preview to session list, omit full notes

Made-with: Cursor
This commit is contained in:
cottongin
2026-03-23 00:06:09 -04:00
parent 656d9c3bf6
commit e9f1b89d44
2 changed files with 54 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ const db = require('../database');
const { triggerWebhook } = require('../utils/webhooks');
const { getWebSocketManager } = require('../utils/websocket-manager');
const { startMonitor, stopMonitor, getMonitorSnapshot } = require('../utils/ecast-shard-client');
const { computeNotesPreview } = require('../utils/notes-preview');
const router = express.Router();
@@ -21,7 +22,11 @@ router.get('/', (req, res) => {
try {
const sessions = db.prepare(`
SELECT
s.*,
s.id,
s.created_at,
s.closed_at,
s.is_active,
s.notes,
COUNT(sg.id) as games_played
FROM sessions s
LEFT JOIN session_games sg ON s.id = sg.session_id
@@ -29,7 +34,12 @@ router.get('/', (req, res) => {
ORDER BY s.created_at DESC
`).all();
res.json(sessions);
const result = sessions.map(({ notes, ...session }) => {
const { has_notes, notes_preview } = computeNotesPreview(notes);
return { ...session, has_notes, notes_preview };
});
res.json(result);
} catch (error) {
res.status(500).json({ error: error.message });
}