From 034475de6ddc54eb1a57de278048e1dd16d6f358 Mon Sep 17 00:00:00 2001 From: Melson Zacharias Date: Tue, 27 Sep 2022 23:11:03 +0530 Subject: [PATCH] Update milestones to add completed list --- databases/milestone/README.md | 17 +++++++++++++++-- nodejs-deep-dive/milestone/README.md | 27 +++++++++++++++++++++++---- testing/jest/README.md | 16 ++++++++++++---- testing/milestone/README.md | 1 + 4 files changed, 51 insertions(+), 10 deletions(-) diff --git a/databases/milestone/README.md b/databases/milestone/README.md index 4da52fa..71875d1 100644 --- a/databases/milestone/README.md +++ b/databases/milestone/README.md @@ -36,17 +36,22 @@ When running this program from the command line, it should print to-dos from the My Todo-list Overdue -24. [x] Submit assignment 2022-07-10 +24. [ ] Submit assignment 2022-07-10 Due Today -25. [x] Pay rent +25. [ ] Pay rent 28. [ ] Service vehicle Due Later 26. [ ] File taxes 2022-07-14 27. [ ] Call Acme Corp. 2022-07-14 + + +Completed Items +20. [x] Buy Groceries +22. [x] Clean apartment ``` - The output format is the same as the To-do assignment in the previous level, except that this time you also have to print the `id` of the row as the first column. Make sure to remove any leading or trailing spaces while printing the todo item. @@ -84,6 +89,10 @@ module.exports = (sequelize, DataTypes) => { console.log("Due Later"); // FILL IN HERE + console.log("\n"); + + console.log("Completed Items"); + // FILL IN HERE } static async overdue() { @@ -98,6 +107,10 @@ module.exports = (sequelize, DataTypes) => { // FILL IN HERE TO RETURN ITEMS DUE LATER } + static async completed() { + // FILL IN HERE TO RETURN ITEMS DUE LATER + } + static async markAsComplete(id) { // FILL IN HERE TO MARK AN ITEM AS COMPLETE diff --git a/nodejs-deep-dive/milestone/README.md b/nodejs-deep-dive/milestone/README.md index b226670..69ccd4e 100644 --- a/nodejs-deep-dive/milestone/README.md +++ b/nodejs-deep-dive/milestone/README.md @@ -13,16 +13,21 @@ Overdue Due Today -[x] Pay rent +[ ] Pay rent [ ] Service vehicle Due Later [ ] File taxes 2022-07-23 [ ] Pay electric bill. 2022-07-23 + + +Completed Items +[x] Buy Groceries +[x] Clean apartment ``` -Here is the template you should use to write the program. You are expected to complete four functions namely `overdue`, `dueToday`, `dueLater` and `toDisplayableList`. +Here is the template you should use to write the program. You are expected to complete four functions namely `overdue`, `dueToday`, `dueLater`, `completed` and `toDisplayableList`. ```javascript const todoList = () => { @@ -58,6 +63,14 @@ const todoList = () => { // .. } + const completed = () => { + // Write the date check condition here and return the array of todo items that are completed accordingly. + // FILL YOUR CODE HERE + // .. + // .. + // .. + } + const toDisplayableList = (list) => { // Format the To-Do list here, and return the output string as per the format given above. // FILL YOUR CODE HERE @@ -67,7 +80,7 @@ const todoList = () => { // return OUTPUT_STRING } - return { all, add, markAsComplete, overdue, dueToday, dueLater, toDisplayableList }; + return { all, add, markAsComplete, overdue, dueToday, dueLater, completed, toDisplayableList }; } // ####################################### # @@ -114,12 +127,18 @@ let itemsDueLater = todos.dueLater() let formattedItemsDueLater = todos.toDisplayableList(itemsDueLater) console.log(formattedItemsDueLater) console.log("\n\n") + +console.log("Completed Items") +let completedItems = todos.completed() +let formattedCompletedItems = todos.toDisplayableList(completedItems) +console.log(formattedCompletedItems) +console.log("\n\n") ``` ## Please read the following notes: -1. For to-dos that are due today, do not show the date. For all other to-dos, show the date. +1. For to-dos that are due today or is completed, do not show the date. For all other to-dos, show the date. 2. Do not print anything (using `console.log` for example) in the code you write. All methods should just return a value - it is the calling code's responsibility to print to screen (like in `console.log todos.toDisplayableList(laterdues)`). This means `toDisplayableList` should return a printable string. 3. Do not implement any extra features since this makes grading your assignments difficult. For the given input, the output should be exactly as given in the assignment. 4. Save the completed code using the template into a file named `index.js` for submission. diff --git a/testing/jest/README.md b/testing/jest/README.md index 165ca1d..7d371a4 100644 --- a/testing/jest/README.md +++ b/testing/jest/README.md @@ -117,22 +117,30 @@ const todoList = () => { const overdue = () => { return all.filter( - (item) => item.dueDate < new Date().toLocaleDateString("en-CA") + (item) => + item.dueDate < new Date().toLocaleDateString("en-CA") && !item.completed ); }; const dueToday = () => { return all.filter( - (item) => item.dueDate === new Date().toLocaleDateString("en-CA") + (item) => + item.dueDate === new Date().toLocaleDateString("en-CA") && + !item.completed ); }; const dueLater = () => { return all.filter( - (item) => item.dueDate > new Date().toLocaleDateString("en-CA") + (item) => + item.dueDate > new Date().toLocaleDateString("en-CA") && !item.completed ); }; - return { all, add, markAsComplete, overdue, dueToday, dueLater }; + + const completed = () => { + return all.filter((item) => item.completed); + }; + return { all, add, markAsComplete, overdue, dueToday, dueLater, completed }; }; module.exports = todoList; diff --git a/testing/milestone/README.md b/testing/milestone/README.md index c8a807b..c75ed3b 100644 --- a/testing/milestone/README.md +++ b/testing/milestone/README.md @@ -9,6 +9,7 @@ To complete this milestone target, you have to implement tests for your Todo app 3. A test that checks retrieval of overdue items. 4. A test that checks retrieval of due today items. 5. A test that checks retrieval of due later items. +6. A test that checks retrieval of completed items. ## You should also