fixed check command
This commit is contained in:
parent
05c448dcc5
commit
17637fe750
1 changed files with 25 additions and 24 deletions
|
|
@ -2228,6 +2228,12 @@ async function logTask(username, userColor, task) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the tasks of a given user. If the user has tasks, the function returns an object with a status of 200 and a formatted string of the user's tasks. If the user has no tasks, the function returns an object with a status indicating the error and an error message.
|
||||||
|
*
|
||||||
|
* @param {string} name - The name of the user whose tasks are to be checked.
|
||||||
|
* @returns {Object} An object with a status and body. The status is 200 if the user has tasks, and the body contains a formatted string of the user's tasks. If the user has no tasks, the status indicates the error and the body contains an error message.
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
* Checks the tasks of a given user. If the user has tasks, the function returns an object with a status of 200 and a formatted string of the user's tasks. If the user has no tasks, the function returns an object with a status indicating the error and an error message.
|
* Checks the tasks of a given user. If the user has tasks, the function returns an object with a status of 200 and a formatted string of the user's tasks. If the user has no tasks, the function returns an object with a status indicating the error and an error message.
|
||||||
*
|
*
|
||||||
|
|
@ -2271,35 +2277,30 @@ async function checkTasks(name, completed = false) {
|
||||||
|
|
||||||
// format incomplete tasks into string: 1. task 1 | 2. task 2 | 3. task 3...
|
// format incomplete tasks into string: 1. task 1 | 2. task 2 | 3. task 3...
|
||||||
let reply = `${name}'s ${label} {taskName}s (${filteredTasks.length}) : `;
|
let reply = `${name}'s ${label} {taskName}s (${filteredTasks.length}) : `;
|
||||||
let taskIndex;
|
for (
|
||||||
for (let i = 0; i < filteredTasks.length; i++) {
|
let taskIndex = 0;
|
||||||
|
taskIndex < tasks[username].todos.length;
|
||||||
|
taskIndex++
|
||||||
|
) {
|
||||||
// get index of task by task name
|
// get index of task by task name
|
||||||
taskIndex =
|
let currentTask = tasks[username].todos[taskIndex];
|
||||||
tasks[username].todos.findIndex(
|
if (!completed) {
|
||||||
(t) =>
|
if (currentTask.done) {
|
||||||
t.text.toLowerCase() === filteredTasks[i].text.toLowerCase()
|
continue;
|
||||||
) + 1;
|
}
|
||||||
|
|
||||||
reply += `${taskIndex}. ${filteredTasks[i].focus ? "(ongoing)" : ""} ${
|
reply += `${taskIndex + 1}. ${
|
||||||
filteredTasks[i].text
|
currentTask.focus ? "(ongoing)" : ""
|
||||||
} | `;
|
} ${currentTask.text} | `;
|
||||||
|
} else {
|
||||||
|
if (!currentTask.done) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
reply += `${taskIndex + 1}. ${currentTask.text} | `;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
reply = reply.slice(0, -3);
|
reply = reply.slice(0, -3);
|
||||||
|
|
||||||
// format completed tasks into string: 1. task 1 | 2. task 2 | 3. task 3...
|
|
||||||
// reply += `\n|| completed tasks (${completedTasks.length}) : `;
|
|
||||||
|
|
||||||
// for (let j = 0; j < completedTasks.length; j++) {
|
|
||||||
// taskIndex =
|
|
||||||
// tasks[username].todos.findIndex(
|
|
||||||
// (t) =>
|
|
||||||
// t.text.toLowerCase() ===
|
|
||||||
// completedTasks[j].text.toLowerCase()
|
|
||||||
// ) + 1;
|
|
||||||
// reply += `${taskIndex}. ${completedTasks[j].text} | `;
|
|
||||||
// }
|
|
||||||
// reply = reply.slice(0, -3);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
status: 200,
|
status: 200,
|
||||||
body: {
|
body: {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue