diff --git a/lib/index.js b/lib/index.js index 21a0b6b..fa92703 100644 --- a/lib/index.js +++ b/lib/index.js @@ -6,8 +6,8 @@ const Obz = require('obz') * @typedef {import('ppppp-db').RecPresent} RecPresent * @typedef {import('ppppp-db').Tangle} Tangle * @typedef {ReturnType} DBTangle - * @typedef {'none'|'all'|`newest-${number}`|`oldest-${number}`|'record'|'set'} GoalDSL - * @typedef {'none'|'all'|'newest'|'oldest'|'record'|'set'} GoalType + * @typedef {'none'|'all'|`newest-${number}`|'record'|'set'} GoalDSL + * @typedef {'none'|'all'|'newest'|'record'|'set'} GoalType * @typedef {[number, number]} Range * @typedef {{ id: string, type: GoalType, count: number }} Goal */ @@ -85,13 +85,6 @@ class GoalImpl { return } - const matchO = goalDSL.match(/^oldest-(\d+)$/) - if (matchO) { - this.#type = 'oldest' - this.#count = Number(matchO[1]) - return - } - throw new Error(`Unrecognized goal DSL: ${goalDSL}`) } @@ -139,9 +132,6 @@ function initGoals(peer, config) { case 'newest': const start = Math.max(0, maxDepth - goal.count + 1) return [start, maxDepth] - case 'oldest': - const end = Math.min(maxDepth, goal.count - 1) - return [0, end] } } diff --git a/test/goals.test.js b/test/goals.test.js index dc60fee..6918113 100644 --- a/test/goals.test.js +++ b/test/goals.test.js @@ -79,6 +79,11 @@ test('getRecordPurpose', async (t) => { domain: 'post', data: { text: 'm2' }, }) + const post3 = await p(alice.db.feed.publish)({ + account: aliceID, + domain: 'post', + data: { text: 'm3' }, + }) const feedID = alice.db.feed.getID(aliceID, 'post') @@ -89,8 +94,8 @@ test('getRecordPurpose', async (t) => { const purpose = alice.goals.getRecordPurpose(post2) assert.equal(purpose, 'goal', 'purpose is "goal"') - alice.goals.set(feedID, 'oldest-1') - assert('set goal to oldest-1') + alice.goals.set(feedID, 'newest-1') + assert('set goal to newest-1') const purpose2 = alice.goals.getRecordPurpose(post2) assert.equal(purpose2, 'none', 'purpose2 is "none"')