perf: server-side search + pagination for topics (30 per page)
Loads only 30 topics at a time with server-side search instead of fetching all 6000+ topics. Debounced search input, pagination, selected-only filter. Much faster for large Victron brokers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -11,11 +11,15 @@ import { getDb } from '../../db/index';
|
||||
|
||||
const router = Router({ mergeParams: true });
|
||||
|
||||
// GET /api/mqtt/brokers/:brokerId/topics
|
||||
// GET /api/mqtt/brokers/:brokerId/topics?search=grid&selected=1&limit=50&offset=0
|
||||
router.get('/', (req, res): void => {
|
||||
try {
|
||||
const brokerId = parseInt(req.params.brokerId);
|
||||
res.json(getTopicsForBroker(brokerId));
|
||||
const search = req.query.search as string | undefined;
|
||||
const selectedOnly = req.query.selected === '1';
|
||||
const limit = parseInt(req.query.limit as string) || 50;
|
||||
const offset = parseInt(req.query.offset as string) || 0;
|
||||
res.json(getTopicsForBroker(brokerId, { search, selectedOnly, limit, offset }));
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: (err as Error).message });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user