Skip to content

Commit 9708574

Browse files
committed
changes from review
1 parent c41e239 commit 9708574

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

controllers/gog.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,9 @@ const expand = async function(primitiveEntity, GENERATOR=undefined, CREATOR=unde
381381
}
382382

383383
// Get the Annotations targeting this Entity from the db. Remove _id property.
384-
let matches = await db.find(queryObj).toArray()
384+
// Cap the read for parity with the client's historical findByTargetId (limit=100), which
385+
// also bounds the query for pathological high-fan-in objects.
386+
let matches = await db.find(queryObj).limit(100).toArray()
385387
matches = matches.map(o => {
386388
delete o._id
387389
return o
@@ -443,6 +445,8 @@ const expandedId = async function (req, res, next) {
443445
res.set(utils.configureWebAnnoHeadersFor(match))
444446
res.set("Cache-Control", "max-age=86400, must-revalidate")
445447
res.set(utils.configureLastModifiedHeader(match))
448+
// Include current version for optimistic locking (parity with GET /v1/id/:_id)
449+
res.set("Current-Overwritten-Version", match.__rerum?.isOverwritten ?? "")
446450
// No GENERATOR/CREATOR filter: merge every current targeting Annotation, matching the
447451
// client's historical expand() behavior (its checkMatch is short-circuited to true).
448452
let expanded = await expand(match)

0 commit comments

Comments
 (0)