Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update milestones to add completed list #232

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions databases/milestone/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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() {
Expand All @@ -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

Expand Down
27 changes: 23 additions & 4 deletions nodejs-deep-dive/milestone/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -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
Expand All @@ -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 };
}

// ####################################### #
Expand Down Expand Up @@ -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.
Expand Down
16 changes: 12 additions & 4 deletions testing/jest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions testing/milestone/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down