openvibers/openvibe.search Commits

Document counts: the tombstone sum is cast to bigint. On PostgreSQL SUM of a bigint column is numeric, which openvibe-sdk/db returns as exact text, so /api/ready's details reported the count as a string. npm test 12/12.

OP OpenVibers committed 28 Sept 2026 · e2474e2cd8 · 1 file, +1 −1


Changes

ddiff --git a/server/store.js b/server/store.js
iindex 02b4729..29e4d39 100644
---- a/server/store.js
++++ b/server/store.js
@@@ -34,7 +34,7 @@ function createStore({ db, engine, outbox, purges = null, now = () => Date.now()
insFacet: db.prepare('INSERT INTO doc_facets (rid, key, value) VALUES (?, ?, ?) ON CONFLICT DO NOTHING'),
ownerPage: db.prepare(`SELECT rid, type, id, revision, deleted, hash, exposure, indexed_at FROM documents
WHERE owner = @owner AND (@type::text IS NULL OR type = @type) AND rid > @after ORDER BY rid LIMIT @limit`),
-- counts: db.prepare(`SELECT COUNT(*) AS total, SUM(deleted) AS tombstones,
++ counts: db.prepare(`SELECT COUNT(*) AS total, COALESCE(SUM(deleted), 0)::bigint AS tombstones,
SUM(CASE WHEN exposure = 3 THEN 1 ELSE 0 END) AS public_listed,
SUM(CASE WHEN exposure = 2 THEN 1 ELSE 0 END) AS public_unlisted,
SUM(CASE WHEN exposure = 1 THEN 1 ELSE 0 END) AS restricted FROM documents`),