Skip to content

Commit b69e8a8

Browse files
author
Nik
committed
AIS Etappe 2: fix DB-Script
1 parent 9b69f2b commit b69e8a8

2 files changed

Lines changed: 12 additions & 13 deletions

File tree

‎apps/ais/backend/src/index.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerSpec));
3535
app.use((error, _req, res, _next) => {
3636
console.error(error);
3737

38-
res.status(500).json({
39-
error: "internal-error",
40-
message: "Internal server error",
41-
details: []
38+
res.status(error.status || 500).json({
39+
error: error.code || "internal-error",
40+
message: error.message || "Internal server error",
41+
details: error.details || []
4242
});
4343
});
4444

‎apps/ais/backend/src/routes/sips.js‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -287,20 +287,19 @@ router.post("/", async (req, res, next) => {
287287
a.record_did,
288288
a.sip_package_hash,
289289
a.accepted_at,
290-
r.snapshot_hash,
290+
(
291+
SELECT snapshot_hash
292+
FROM ais_record_snapshots
293+
WHERE record_id = ar.id
294+
ORDER BY version DESC
295+
LIMIT 1
296+
) AS snapshot_hash,
291297
sr.receipt
292298
FROM ais_aips a
293299
JOIN ais_records ar ON ar.aip_id = a.aip_id
294-
LEFT JOIN LATERAL (
295-
SELECT snapshot_hash
296-
FROM ais_record_snapshots
297-
WHERE record_id = ar.id
298-
ORDER BY version DESC
299-
LIMIT 1
300-
) r ON true
301300
LEFT JOIN ais_submission_receipts sr ON sr.aip_id = a.aip_id
302301
WHERE a.record_did = $1
303-
FOR UPDATE
302+
FOR UPDATE OF a, ar
304303
`,
305304
[sip.record.did]
306305
);

0 commit comments

Comments
 (0)