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

Modify dateOfLastVisit to use LocalDate instead of String #171

Conversation

rayray39
Copy link

@rayray39 rayray39 commented Oct 31, 2024

This PR completed the following things

  1. update internal representation of DateOfLastVisit to be LocalDate instead of a String.
  2. restricts the date of last visit to be no later than today's date (i.e., the user will not be able to add a contact with a date of last visit that is either tomorrow or later).

closes #141
closes #166

@rayray39 rayray39 added this to the v1.5 milestone Oct 31, 2024
Copy link

codecov bot commented Oct 31, 2024

Codecov Report

Attention: Patch coverage is 55.55556% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...a/seedu/address/model/person/PersonComparator.java 20.00% 6 Missing and 6 partials ⚠️
Files with missing lines Coverage Δ Complexity Δ
...va/seedu/address/model/person/DateOfLastVisit.java 96.00% <100.00%> (+0.34%) 11.00 <6.00> (+2.00)
...a/seedu/address/model/person/PersonComparator.java 50.00% <20.00%> (-38.89%) 5.00 <0.00> (ø)

... and 11 files with indirect coverage changes

@rayray39 rayray39 added alpha-bug type.Chore Something that needs to be done, but not a story, bug, or an epic. e.g. Move testing code into a new priority.Medium Nice to have severity.Medium A flaw that causes occasional inconvenience to some users, but they can continue to use the product. labels Oct 31, 2024
Copy link
Collaborator

@AbdulrahmanAlRammah AbdulrahmanAlRammah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall good changes, but I have some concerns regarding the testing. Please see comments.

src/test/java/seedu/address/testutil/TypicalPersons.java Outdated Show resolved Hide resolved
// Days 01-31 for other months
// -------------------
public static final String MESSAGE_CONSTRAINTS = "Date of last visit should be in dd-MM-yyyy format.\n"
+ "Ensure that the month is 01-12 and the date is not later than today. ";
Copy link
Collaborator

@AbdulrahmanAlRammah AbdulrahmanAlRammah Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand the ensure month is 01-12 comment. Do you mean ensure that month is after day?

Edit: Oh I think you mean ensure the month is typed with 2 digits, but I think you can take this as a given since we requested dd-MM-yyyy format. You can say "Date of Last Visit should be in exactly dd-MM-yyyy format. Also it is good to add an example in the error message.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup that was the intention and i will update the error message as suggested

@@ -12,7 +13,7 @@ public class PersonComparator {
public static final String NAME = "name";
public static final String DATE_OF_LAST_VISIT = "date of last visit";
public static final String EARLIEST_VALID_DATE = "01-01-0001";
public static final String LATEST_VALID_DATE = "31-12-9999";
public static final String LATEST_VALID_DATE = LocalDate.now().format(DateOfLastVisit.DATE_TIME_FORMATTER);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be better to not change this. The LATEST_VALID_DATE is meant to distinguish entries with no date of last visit from those that do have. I believe in this case if you set the date of last visit to be today for one of the entries and then sort the entry with dolv as today will be mixed with those without date of last visit. Hence, it is better to keep the value as is or to set it as today + 1.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DateOfLastVisit has been updated to accept a date no later than today, which means that a date of "31-12-9999" would not be possible. I have updated the comparators for date of last visit to not use EARLIEST_VALID_DATE and LATEST_VALID_DATE. Although this makes the code slightly longer and less clean, the functionality works as expected.

Copy link
Collaborator

@AbdulrahmanAlRammah AbdulrahmanAlRammah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AbdulrahmanAlRammah AbdulrahmanAlRammah merged commit 1d68778 into AY2425S1-CS2103-F10-2:master Nov 2, 2024
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alpha-bug priority.Medium Nice to have severity.Medium A flaw that causes occasional inconvenience to some users, but they can continue to use the product. type.Chore Something that needs to be done, but not a story, bug, or an epic. e.g. Move testing code into a new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DateOfLastVisit field allows adding future dates Modify DateOfLastVisit to store DateTime instead of strings
2 participants