diff --git a/index.js b/index.js index 161a331..61963e0 100644 --- a/index.js +++ b/index.js @@ -7,6 +7,7 @@ const { author, descending, paginate, + batch, live, toPullStream, toCallback, @@ -41,7 +42,7 @@ exports.init = function init(sbot) { sbot.metafeeds.findOrCreate( mf, (f) => f.feedpurpose === 'indexes', - { feedpurpose: 'indexes', feedformat: 'bendy butt' }, + { feedpurpose: 'indexes', feedformat: 'bendybutt-v1' }, (err, indexesMF) => { if (err) return reject(err) else resolve(indexesMF) @@ -116,14 +117,10 @@ exports.init = function init(sbot) { const matchesQuery = QL0.toOperator(queryQL0) return cat([ // Old - pull( - sbot.db.query( - where(and(matchesQuery, gt(latestSequence, 'sequence'))), - paginate(50), - toPullStream() - ), - pull.map(pull.values), - pull.flatten() + sbot.db.query( + where(and(matchesQuery, gt(latestSequence, 'sequence'))), + batch(75), + toPullStream() ), // Live sbot.db.query(where(matchesQuery), live(), toPullStream()), diff --git a/package.json b/package.json index 33303b1..3b60e28 100644 --- a/package.json +++ b/package.json @@ -13,11 +13,11 @@ "dependencies": { "pull-cat": "^1.1.11", "pull-stream": "^3.6.14", - "ssb-db2": "github:ssb-ngi-pointer/ssb-db2#publishAs-simple", + "ssb-db2": "github:ssb-ngi-pointer/ssb-db2#support-bendy-butt", "ssb-subset-ql": "~0.2.0" }, "peerDependencies": { - "ssb-meta-feeds": "~0.15.0" + "ssb-meta-feeds": ">=0.18.0" }, "devDependencies": { "husky": "^4.3.0", @@ -31,7 +31,7 @@ "ssb-caps": "^1.1.0", "ssb-fixtures": "^2.4.1", "ssb-keys": "^8.2.0", - "ssb-meta-feeds": "~0.15.0", + "ssb-meta-feeds": "~0.18.0", "tap-bail": "^1.0.0", "tap-spec": "^5.0.0", "tape": "^5.2.2" diff --git a/test/index.js b/test/index.js index 87ba017..b85c6a9 100644 --- a/test/index.js +++ b/test/index.js @@ -96,10 +96,12 @@ test('update index feed for votes a bit', (t) => { }) // Make it slow so we can cancel in between + let stopped = false const PERIOD = 200 const originalPublishAs = sbot.db.publishAs sbot.db.publishAs = function (keys, content, cb) { setTimeout(() => { + if (stopped) return originalPublishAs.call(sbot.db, keys, content, cb) }, PERIOD) } @@ -114,9 +116,10 @@ test('update index feed for votes a bit', (t) => { setTimeout(() => { sbot.indexFeedWriter.stop({ author: sbot.id, type: 'vote' }) + stopped = true t.pass('stopped task') sbot.close(true, t.end) - }, PERIOD * 3.75) + }, PERIOD * 3.5) } ) })