def get_by_capacity_simulation(cls, free_space, company, facility, permission): rooms = [] print('free space:') print(type(free_space)) query = { '$and': [{ 'company': company }, { 'facility': facility }, { 'permission': { '$not': { '$gt': permission } } }, { 'capacity': { '$gt': (free_space - 1) } }] } data = Database.findSimulation('rooms', query) if data is not None: for room in data: rooms.append(cls(**room)) return rooms
def get_schedules_simulation(cls, user_email, date=None, start_time=None, end_time=None, room_id=None): """ :return: list of schedule's object that represent the schedule of the user's email """ email_query = {'email': user_email} date_query = {'date': date} if date is not None else {} room_query = {'room_id': room_id} if room_id is not None else {} begin_query = { 'begin_meeting': start_time } if start_time is not None else {} end_query = {'end_meeting': end_time} if end_time is not None else {} # query = {'$and': [email_query, date_query, room_query, begin_query, end_query]} query = {'email': user_email} schedules = [] data = Database.findSimulation('schedules', query) print(query) print(date) if data is not None: for sched in data: schedules.append(cls(**sched)) return schedules
def get_by_company_simulation(cls, company): rooms = [] data = Database.findSimulation('rooms', {'company': company}) if data is not None: for room in data: rooms.append(cls(**room)) return rooms
def find_by_facility_simulation(cls, facility): all_rooms = [] query = {'facility': facility} data = Database.findSimulation('rooms', query) if data is not None: for room in data: all_rooms.append(cls(**room)) return all_rooms
def get_by_company_simulation(cls, company): users = [] data = Database.findSimulation('users', {'company': company}) if data is not None: for user in data: users.append(cls(**user)) # print(len(users)) # print(users) return set(users)
def get_by_order_simulation(cls, order_id): all_scheds = [] query = {'order_id': order_id} data = Database.findSimulation('schedules', query) if data is not None: for sched in data: all_scheds.append(cls(**sched)) return all_scheds
def get_by_date_and_hour_simulation(cls, date, begin_hour, end_hour): schedules = [] query = {'$and': [{'date': date}, {'begin_meeting': begin_hour}]} # query = {'$and': [{'date': date}, # {'$or': [{'$gt': {'begin_meeting': end_hour}}, {'$st': {'end_meeting': begin_hour}}]}]} data = Database.findSimulation('schedules', query) if data is not None: for sched in data: schedules.append(cls(**sched)) return schedules
def get_by_room_and_date_and_hour_simulation(cls, _id, date, begin_hour, end_hour): schedules = [] query = {'$and': [{'date': date}, {'room_id': _id}]} data = Database.findSimulation('schedules', query) if data is not None: for schedule in data: if int(schedule.end_meeting) <= int(end_hour) and int( schedule.begin_meeting) >= int(begin_hour): schedules.append(cls(**schedule)) return schedules
def get_by_room_and_date_simulation(cls, _id, date): """ :return: list of schedule's object that represent the schedule in the given room_id on the given date """ schedules = [] query = {'$and': [{'date': date}, {'room_id': _id}]} data = Database.findSimulation('schedules', query) if data is not None: for sched in data: schedules.append(cls(**sched)) return schedules
def get_by_facility_simulation(cls, company, facility): data = Database.findSimulation( 'rooms', {'$and': [{ 'company': company }, { 'facility': facility }]}) rooms = [] if data is not None: for room in data: rooms.append(cls(**room)) return rooms
def get_by_email_and_date_and_hour_simulation(cls, email, date, begin_hour, end_hour): ###need to change the queary schedules = [] query = {'$and': [{'date': date}, {'email': email}]} data = Database.findSimulation('schedules', query) if data is not None: for sched in data: if cls.check_time_interval(sched, begin_hour, end_hour) == True: schedules.append(cls(**sched)) return schedules
def get_by_room_simulation(cls, room_id): """ :param room_id: :return: list of schedule's object that represent the schedule in the given room_id """ schedules = [] data = Database.findSimulation('schedules', {'room_id': room_id}) if data is not None: for sched in data: schedules.append(cls(**sched)) return schedules
def get_facilities_simulation(company): """ :param company: :return: List of company's facilities """ facility_dict = Database.findSimulation('facilities', {'company': company}) facilities = [] for facility in facility_dict: facility = facility['facility'] facilities.append(facility) return facilities
def get_num_employees_facility_simulation(company_id, facility_id=None): if facility_id is None: query = {'company': company_id} else: query = { '$and': [{ 'facility': facility_id }, { 'company': company_id }] } emps = Database.findSimulation('users', query) if emps is None: return return emps.count(True)
def get_num_rooms_facility_simulation(company_id, facility_id=None): if facility_id is None: query = {'company': company_id} else: query = { '$and': [{ 'facility': facility_id }, { 'company': company_id }] } rooms = Database.findSimulation('rooms', query) if rooms is None: return return rooms.count(True)
def find_by_date_and_time_facility_simulation(cls, date, beign, end, facility): orders = [] intersection = { '$or': [{ '$and': [{ 'start_time': { '$not': { '$gte': end } } }, { 'end_time': { '$gte': end } }] }, { '$and': [{ 'start_time': { '$not': { '$gte': beign } } }, { 'end_time': { '$gt': beign } }] }] } query = { '$and': [{ 'date': date }, { 'facility': facility }, intersection] } data = Database.findSimulation('orders', query) for order in data: orders.append(cls(**order)) return orders