feat:抢单大厅数据排列优化

This commit is contained in:
2026-10-25 14:41:13 +08:00
parent 9c620d39cb
commit d787d3c364
6 changed files with 124 additions and 5 deletions
@@ -62,10 +62,13 @@ export async function createRealtimeEvent(input: {
export async function listRealtimeEventsAfter(eventId: number, limit = 500) {
const result = await query<RealtimeEventRow>(
`
SELECT * FROM realtime_events
WHERE id > $1
SELECT * FROM (
SELECT * FROM realtime_events
WHERE id > $1
ORDER BY id DESC
LIMIT $2
) replay_window
ORDER BY id ASC
LIMIT $2
`,
[Math.max(0, Number(eventId) || 0), Math.min(500, Math.max(1, Number(limit) || 500))],
)