omou-org / front-end

2 stars 1 forks source link

Tutoring Scheduling #783

Closed CalvinFronda closed 3 years ago

CalvinFronda commented 3 years ago

What needs to be done.

We need to calculate instructor availability based on given constraints:

  1. start_date [datetime]
  2. end_date [datetime]
  3. days_of_reoccurrence [array]
  4. duration [time]
  5. 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.

  1. Check if the instructor can teach the class
  2. Check if the instructor is already teaching at a certain time and day
  3. Check if the instructor is OOO
  4. Check if the instructor is working on certain days & times
// Query
instructorTutoringAvailabilities(
                             start_time: Date!,
                             end_time: Date!,
                             days_of_reoccurrence: [array!],
                             duration: int,
                             topic: str){
                                    listOfInstructors
                    }

// returns 
{
    "data" : {
        "listOfInstructors" : [{
            "instructor" : {
                    "id" : 2,
                    "firstName" : Bob
                    "lastName" : Yim
                    "biography" : "Bob is a teacher"    
            }   
            "tutoringAvailability" : {
                    "monday" : [false, true, true, false]
                    "tuesday" : [true, true, true, false]
                    "wedndesday" : [false, false, false, false]
                    "thursday" : [false, false, false, false]
                    "friday" : [true, false, false, false]
                    "saturday" : [false, false, false, false]
                    "sunday" : [false, false, false, false]
            }
        },
        {
            "instructor" : {
                    "id" : 4,
                    "firstName" : Tim
                    "lastName" : Yang
                    "biography" : "Tim is a teacher"    
                }   
            "tutoringAvailability" : {
                    "monday" : [true, false, false, false]
                    "tuesday" : [false, false, false, false]                        
                                         "wedndesday" : [false, false, false, false]
                                         "thursday" : [false, false, false, false]  
                    "friday" : [false, false, false, false]
                    "saturday" : [false, false, false, false]                       
                                          "sunday" : [false, false, false, false]
                }
            },
        ]
}

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:

time : datetime day_of_week: str business_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 : int day_of_week: str business_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:

{
    "monday" : [false, true, true, false]
    "tuesday" : [true, true, true, false]
    "wedndesday" : [false, false, false, false]
    "thursday" : [false, false, false, false]
    "friday" : [true, false, false, false]
    "saturday" : [false, false, false, false]
    "sunday" : [false, false, false, false]

}

set_instructor_availabilities:

instructor_id : int instructor_availabilities_map: dict

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 :

{
    "instructor" : {
            "id" : 4,
            "firstName" : Tim
            "lastName" : Yang
            "biography" : "Tim is a teacher"    
        }   
    "tutoringAvailability" : {
                         "monday" : [false, true, true, false]
                         "tuesday" : [true, true, true, false]
                         "wedndesday" : [false, false, false, false]
                         "thursday" : [false, false, false, false]
                         "friday" : [true, false, false, false]
                         "saturday" : [false, false, false, false]
                         "sunday" : [false, false, false, false]
        }
    },
}
CalvinFronda commented 3 years ago

https://github.com/omou-org/mainframe/issues/222