From d6e03c765e8c22b123c235fde35ce4fd385a9d51 Mon Sep 17 00:00:00 2001 From: Natalie <78037386+CuriousMagpie@users.noreply.github.com> Date: Thu, 17 Apr 2025 13:34:55 -0400 Subject: [PATCH] fix: correct number of available completed todos for users (#15424) * fix: Correct number of available completed todos for users * fix(test): remove test obsoleted by changes to GET completed --------- Co-authored-by: Kalista Payne --- .../integration/tasks/GET-tasks_user.test.js | 28 ------------------- website/server/libs/tasks/index.js | 6 +--- 2 files changed, 1 insertion(+), 33 deletions(-) diff --git a/test/api/v3/integration/tasks/GET-tasks_user.test.js b/test/api/v3/integration/tasks/GET-tasks_user.test.js index 31361d46bd..c08baafce3 100644 --- a/test/api/v3/integration/tasks/GET-tasks_user.test.js +++ b/test/api/v3/integration/tasks/GET-tasks_user.test.js @@ -101,34 +101,6 @@ describe('GET /tasks/user', () => { expect(allCompletedTodos[allCompletedTodos.length - 1].text).to.equal('todo to complete 2'); }); - it('returns only some completed todos if req.query.type is "completedTodos" or "_allCompletedTodos"', async () => { - const LIMIT = 30; - const numberOfTodos = LIMIT + 1; - const todosInput = []; - - for (let i = 0; i < numberOfTodos; i += 1) { - todosInput[i] = { text: `todo to complete ${i}`, type: 'todo' }; - } - const todos = await user.post('/tasks/user', todosInput); - await user.sync(); - const initialTodoCount = user.tasksOrder.todos.length; - - for (let i = 0; i < numberOfTodos; i += 1) { - const id = todos[i]._id; - - await user.post(`/tasks/${id}/score/up`); // eslint-disable-line no-await-in-loop - } - await user.sync(); - - expect(user.tasksOrder.todos.length).to.equal(initialTodoCount - numberOfTodos); - - const completedTodos = await user.get('/tasks/user?type=completedTodos'); - expect(completedTodos.length).to.equal(LIMIT); - - const allCompletedTodos = await user.get('/tasks/user?type=_allCompletedTodos'); - expect(allCompletedTodos.length).to.equal(numberOfTodos); - }); - it('returns dailies with isDue for the date specified', async () => { // @TODO Add required format const startDate = moment().subtract('1', 'days').toISOString(); diff --git a/website/server/libs/tasks/index.js b/website/server/libs/tasks/index.js index 4ad1bb71e0..94acaede40 100644 --- a/website/server/libs/tasks/index.js +++ b/website/server/libs/tasks/index.js @@ -207,11 +207,7 @@ async function getTasks (req, res, options = {}) { query.type = 'todo'; query.completed = false; // Exclude completed todos } else if (type === 'completedTodos' || type === '_allCompletedTodos') { // _allCompletedTodos is currently in BETA and is likely to be removed in future - limit = 30; - - if (type === '_allCompletedTodos') { - limit = 0; // no limit - } + limit = 0; // no limit, the 30/90 days of data for subscribers is handled during cron query.type = 'todo'; query.completed = true;