Add SSE live updates for bestellungen

This commit is contained in:
2026-06-16 19:43:19 +02:00
parent c0f819fd3d
commit a463632772
3 changed files with 211 additions and 1 deletions
+25
View File
@@ -352,3 +352,28 @@ SQL;
'next_limit' => min($totalCount, $limit + $pageSize),
];
}
function get_sales_order_realtime_snapshot(PDO $pdo, int $limit = 1000): array
{
$limit = max(1, min(2000, $limit));
$stmt = $pdo->prepare(
'SELECT id, created_at, updated_at
FROM public.sales_order
ORDER BY updated_at DESC NULLS LAST, id DESC
LIMIT :limit'
);
$stmt->bindValue(':limit', $limit, PDO::PARAM_INT);
$stmt->execute();
$rows = [];
foreach ($stmt->fetchAll() as $row) {
$rows[] = [
'id' => (int) ($row['id'] ?? 0),
'created_at' => (string) ($row['created_at'] ?? ''),
'updated_at' => (string) ($row['updated_at'] ?? ''),
];
}
return $rows;
}