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 <sabrecat@gmail.com>
This commit is contained in:
Natalie
2025-04-17 13:34:55 -04:00
committed by GitHub
parent dd6503d5ef
commit d6e03c765e
2 changed files with 1 additions and 33 deletions

View File

@@ -101,34 +101,6 @@ describe('GET /tasks/user', () => {
expect(allCompletedTodos[allCompletedTodos.length - 1].text).to.equal('todo to complete 2'); 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 () => { it('returns dailies with isDue for the date specified', async () => {
// @TODO Add required format // @TODO Add required format
const startDate = moment().subtract('1', 'days').toISOString(); const startDate = moment().subtract('1', 'days').toISOString();

View File

@@ -207,11 +207,7 @@ async function getTasks (req, res, options = {}) {
query.type = 'todo'; query.type = 'todo';
query.completed = false; // Exclude completed todos 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 } else if (type === 'completedTodos' || type === '_allCompletedTodos') { // _allCompletedTodos is currently in BETA and is likely to be removed in future
limit = 30; limit = 0; // no limit, the 30/90 days of data for subscribers is handled during cron
if (type === '_allCompletedTodos') {
limit = 0; // no limit
}
query.type = 'todo'; query.type = 'todo';
query.completed = true; query.completed = true;