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

Debug time issues #242

Merged
merged 12 commits into from
Nov 4, 2020
Merged

Conversation

jiaweiteo
Copy link

@jiaweiteo jiaweiteo commented Nov 1, 2020

New changes:
Can only create travel plan with dates that are today or after today. (Prevent invalid/ancient dates etc. 1111-11-11) #210
End date cannot be earlier than start date for both travel plan and accommodation #214
Activity date must be in range of travelplan start date and end date #236
Accommodation start date and end date must be in range of travelplan start date and end date #236
UI show the correct number of days for both travel plan and accommodation #216
Sample data change all dates to start from 2021
Copy/Move command only allow activities to move to travelplan within date range. #236

Wishlist still accept any dates from activity, since it doesnt care about dates till you add it in a travelplan

@jiaweiteo jiaweiteo added this to the v1.4 milestone Nov 1, 2020
@@ -19,8 +18,7 @@
@Override
public CommandResult execute(Model model) {
requireNonNull(model);
model.setTravelPlan(new TravelPlan(new Name("Dummy"), new WanderlustDate("0"), new WanderlustDate("0")),
new TravelPlan(null, null, null));
model.setTravelPlanner(new TravelPlanner(null));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this work? I think it cannot be null tho. "new TravelPlanner()" should work

Copy link
Author

Choose a reason for hiding this comment

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

Hang on let me change it

Copy link
Author

Choose a reason for hiding this comment

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

Ok changed

WanderlustDateTime activityDateTime = activityToCopy.getActivityDateTime();

boolean isValidActivityDateTime = model.isValidActivityDate(activityDateTime,
travelPlanStartDate, travelPlanEndDate);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the date can be abstracted out, just pass the TravelPlan to isValidActivityDate() then in Model, you get the start and end date there.

Copy link
Author

Choose a reason for hiding this comment

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

Ok solved, thanks!

Copy link
Collaborator

@lyeyixian lyeyixian left a comment

Choose a reason for hiding this comment

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

LGTM. But got some abstraction problem I think

WanderlustDateTime activityDateTime = activityToMove.getActivityDateTime();

boolean isValidActivityDateTime = model.isValidActivityDate(activityDateTime,
travelPlanStartDate, travelPlanEndDate);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above.

Copy link
Author

Choose a reason for hiding this comment

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

Changed.

throw new CommandException(MESSAGE_INVALID_STARTANDENDDATE);
}

boolean isValidStartDate = TravelPlan.isStartDateAfterToday(updatedStartDate);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this be put in isValidStartAndEndDate()? So, everything is checked in one method?

Copy link
Author

Choose a reason for hiding this comment

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

No, different error message

throw new ParseException(MESSAGE_INVALID_STARTANDENDDATE);
}

if (!TravelPlan.isStartDateAfterToday(startDate)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above. Or is it becos of 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.

Different error message

* Checks if activity object date time is within the model's travel plan start and end date.
* @return true if activity date is within travel plan start date and end date range.
*/
boolean isValidActivityDate(WanderlustDateTime activityDateTime, WanderlustDate startDate, WanderlustDate endDate);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the JavaDoc for this can put like, see isValidActivityDate() something like that? I not sure tho.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Think this will be considered as duplicate?

Copy link
Author

Choose a reason for hiding this comment

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

What you mean?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm just concern about if this will be considered duplicates code. I think it's OK ba.

return false;
}

if (endDate.getValue().isBefore(travelPlanStartDate.getValue())
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's bad "SLAP" here. Perhaps can just do startDate.isBefore(WanderlustDate)

Copy link
Author

Choose a reason for hiding this comment

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

fixed

WanderlustDate travelPlanStartDate = directory.getStartDate();
WanderlustDate travelPlanEndDate = directory.getEndDate();

if (activityDateTime.getValue().toLocalDate().isBefore(travelPlanStartDate.getValue())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same for all date checking logic in this class

Copy link
Author

Choose a reason for hiding this comment

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

fixed

* too old (Etc, 1111-11-11)
*/
public static boolean isStartDateAfterToday(WanderlustDate startDate) {
return startDate.getValue().compareTo(LocalDate.now()) >= 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

All these getValue() haha, kind of wanna abstract all of them out XD, but see you want or not. I think its ok? Like add a method in WanderlustDate compareTo() so can just call startDate.compareTo() instead of this, need getValue() everytime.

Copy link
Author

Choose a reason for hiding this comment

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

fixed

@jiaweiteo jiaweiteo merged commit ffb86fb into AY2021S1-CS2103-T14-3:master Nov 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants