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

Finish find meeting algorithm and add test cases #6

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

yjzhang111
Copy link
Owner

Complete algorithm in FindMeetingQuery.java and add more edge cases to FindMeetingQueryTest.java

@yjzhang111 yjzhang111 self-assigned this Jun 22, 2020
Copy link
Collaborator

@mutisog mutisog left a comment

Choose a reason for hiding this comment

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

Left some comments.


// Save the result in timeSlotsForRequired
// in case no time slot can be found when optional attendees are included
List<TimeRange> timeSlotsForRequired = new ArrayList<TimeRange>(timeSlots);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it necessary to convert timeSlots to an ArrayList?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I am saving a copy of timeSlots to variable timeSlotsForRequired (in the case where there is no time slot available for optional attendees, I can just return timeSlotsForRequired).

List<TimeRange> timeSlotsForRequired = new ArrayList<TimeRange>(timeSlots);

// Check for the availability of optional attendees
timeSlots = queryForEvent(events, timeSlots, request.getOptionalAttendees());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does "timeSlots" include slots for required attendees, or only optional attendees?

Copy link
Owner Author

Choose a reason for hiding this comment

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

The variable timeSlots is first modified to fit all the required attendees' schedules, and the result is saved in timeSlotsForRequired. Then it goes on to check all the optional attendees, so after line 43, timeSlots include slots for both required and optional attendees. Do you think it is better to change the variable name to something like timeSlotsForAll? (I think the only problem with this is that making a copy of timeSlotsForAll and naming it timeSlotsForRequired does not make a lot of sense) Or do you think it is better to just add some comments here?

Comment on lines 83 to 86
// Case C: |--C---|
// Event: |------|
// |-1-|
// Shorten time period from C to 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. Good use of ASCII art to clarify the algorithm's different scenarios, I like it!
  2. Do 'slot' and 'period' mean the same thing? If yes, I'd suggest standardizing for clarity.
  3. I like how one timeSlot is named "Event". To be complete, what would be the name of the other two timeslots (lines 83 and 85)?

Copy link
Owner Author

Choose a reason for hiding this comment

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

  1. Fixed. 3) I changed Case C and event to their corresponding variable name so it matches with the code better.

Comment on lines 278 to 279
// Have each person have different events. We should see three options because each person has
// split the restricted times.
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does "each person has split the restricted times" mean?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Basically means the events each attendee has split the whole day into 3 options for the request. I've changed the wording so that it's less confusing.

Collection<TimeRange> expected = Arrays.asList();

Assert.assertEquals(expected, actual);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • Should we add a test for the case where no time slots are available?
  • What other edge cases should be considered / are worth testing?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Some other tests are provided in the file as starter code (when the attendees have overlapping/nested events, when there is no time slots available, when there is no attendee at all, etc.)

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.

3 participants