We need to calculate instructor availability based on given constraints:
start_date [datetime]
end_date [datetime]
days_of_reoccurrence [array]
duration [time]
topic [string]
The query will look like this
Issue
You are given a dict of days as keys and an array of booleans as values.
We need to switch the false flag to true if the teacher has available time to teach.
Check if the instructor can teach the class
Check if the instructor is already teaching at a certain time and day
Check if the instructor is OOO
Check if the instructor is working on certain days & times
Each list is created by the start date and incrementing by 30 mins. Say our business hours are 9:00am - 12:00pm on monday. Our monday tutoring availability is "monday" : [false, false, false, false, false, false]
If we converted each boolean to time it would be:
"monday" : [9:00, 9:30, 10:00, 10:30, 11:00, 11:30 ]
Utility functions
I’m working on some helper functions to help solve this ticket.
def time_to_index:
time : datetimeday_of_week: strbusiness_id: int
This function returns the index given the time, day of week and business id. It uses the business_id to find the start time of the business. Then goes through index = time - business_start_time / 30 mins
def index_to_time:
index : intday_of_week: strbusiness_id: int
This function returns the time given the index, day of week and business id.
It uses the business_idto find the start time of the business. Then goes through time = start_time + 30 mins * index
get_business_hours_map:
business_id: int
We would use this to create the initial business availabilities so we could set the instructors availabilities. This uses the business hours start_time and end_time depending on the day.
This function returns a map of business hours given the business_id:
What needs to be done.
We need to calculate instructor availability based on given constraints:
The query will look like this
Issue
You are given a dict of days as keys and an array of booleans as values. We need to switch the false flag to true if the teacher has available time to teach.
Tutoring Availability
Each list is created by the start date and incrementing by 30 mins. Say our business hours are 9:00am - 12:00pm on monday. Our monday tutoring availability is
"monday" : [false, false, false, false, false, false]
If we converted each boolean to time it would be:
"monday" : [9:00, 9:30, 10:00, 10:30, 11:00, 11:30 ]
Utility functions
I’m working on some helper functions to help solve this ticket.
def time_to_index:
This function returns the index given the time, day of week and business id. It uses the
business_id
to find the start time of the business. Then goes throughindex = time - business_start_time / 30 mins
def index_to_time:
This function returns the time given the index, day of week and business id. It uses the
business_id
to find the start time of the business. Then goes throughtime = start_time + 30 mins * index
get_business_hours_map:
We would use this to create the initial business availabilities so we could set the instructors availabilities. This uses the business hours start_time and end_time depending on the day.
This function returns a map of business hours given the
business_id
:set_instructor_availabilities:
This would be used to set the availabilities of a selected instructor based on the business hours map.
This function returns a map of instructor tutoring availabilities with :