def report_volunteer_schedule(volunteer_id, server, sessions):
    
    coll = mg.config_collection(server)
    for vol in coll.find({'volunteer_id':volunteer_id}):
        schdl = vol['schedule']
        print('\n\nFull schedule for {}'.format(translate_volunteer_code(volunteer_id)))
        for day in schdl.keys():
               
            for week in schdl[day].keys():
                
                session_ids = schdl[day][week]
                if len(session_ids) > 0:
                    
                    print(week, day)
                    for session_id in session_ids:
                        
                        session = extract_session(day, week, session_id, sessions)
                        slot = session.get_volunteer_time_slot(volunteer_id)
                        
                        if slot is not None:
                            
                            print('\t'+translate_session_code(session_id)+': session '+session_id[-2:]+
                             ' '+slot)
                        
                else:
                    pass
def store_volunteer_schedules(server, volunteers):

    collection = mg.config_collection(server)

    # write generated volunteer schedules to database
    for volunteer in volunteers.values():
        doc = {}
        doc['volunteer_id'] = volunteer.get_id()
        doc['schedule'] = volunteer.get_schedule()

        collection.insert_one(doc)
def get_scheduled_volunteers(day, week, server):

    collection = mg.config_collection(server)
    
    sess = []
    for result in collection.find({'day':day}):
        sess.append(result)
        
    sess_dict = sess[0]['sessions'][week]
    
    lst = []
    for vol_list in sess_dict.values():
        lst = lst + vol_list
        
    return pd.Series(lst).unique()
def get_scheduled_volunteer_frequencies(day, week, server):
    
    collection = mg.config_collection(server)
    
    sess = []
    for result in collection.find({'day':day}):
        sess.append(result)
        
    sess_dict = sess[0]['sessions'][week]
    freq = {}
    for session_id in sess_dict.keys():
        for vol in sess_dict[session_id]:
            if vol in freq.keys():
                freq[vol] += 1
            else:
                freq[vol] = 1
                
    return freq
def store_rotations(server, sessions):

    collection = mg.config_collection(server)

    # write session information to database
    weeks = ["week1", "week2", "week3", "week4", "week5"]
    days = ["tuesday", "thursday"]

    for day in days:
        doc = {}
        doc['day'] = day
        doc['sessions'] = {}
        for week in weeks:
            doc['sessions'][week] = {}

            for session in sessions[day][week]:
                doc['sessions'][week][
                    session.get_id()] = session.get_time_slots()

        collection.insert_one(doc)