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.
Changes
@@@ -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 documentsWHERE 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`),
@@ -34,7 +34,7 @@ function createStore({ db, engine, outbox, purges = null, now = () => Date.now()
@@ -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'),
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
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`),
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 = 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 = 2 THEN 1 ELSE 0 END) AS public_unlisted,
SUM(CASE WHEN exposure = 1 THEN 1 ELSE 0 END) AS restricted FROM documents`),
SUM(CASE WHEN exposure = 1 THEN 1 ELSE 0 END) AS restricted FROM documents`),