def upload_matches(program: str): instructors = fbread.read_instructors(program) institutions = fbread.read_institutions(program) if instructors == False: return False if institutions == False: return False result = iassorter.sort(instructors, institutions) timestamp = str(calendar.timegm(time.gmtime())) db = dfsapi.get_db() keys = db.child(program).child("matches").shallow().get() if keys.val() != None: db_length = len(keys.val()) if db_length > 10: oldest = min(keys.val()) db.child(program).child("matches").child(oldest).remove() print("Here") json_matches = defaultdict(list) for school in result: for match in result[school]: match_dict = match_to_dict(match) json_matches[school].append(match_dict) db.child(program).child("matches").child(timestamp).child( school).child(match.teacher_name).set(match_dict) db.child(program).child("matches").child(timestamp).child( school).child(match.teacher_name).update({"Locked": False}) return json_matches
def resort(locked_dict: dict, program: str): print("GOING THROUGH RESORT METHOD!!!") result = defaultdict(list) instructors = list() institutions = fbread.read_institutions(program) locked_instructors = list() global global_locked_dict for institution in locked_dict: print("Institution: " + institution) for instructor in locked_dict[institution]: locked_instructors.append(instructor.teacher_name) global_locked_dict[institution].append(instructor) #institution.instructors -= 1 #print("Getting Resorted: " + str(result)) pool_of_instructors = fbread.read_instructors(program) for instructor in pool_of_instructors: if instructor.name not in locked_instructors: instructors.append(instructor) #print("List of Instructors: " + str(instructors)) printInstructorList(instructors) global resorting resorting = True result = sort(instructors, institutions) print("RESORTED RESULT:") print_result(result) return result
def upload_shirtsize(program: str): instructors = fbread.read_instructors(program) shirtsizes = getshirtsize(instructors) db = dfsapi.get_db() for shirt in shirtsizes: db.child(program).child("shirts").child(shirt).set(shirtsizes[shirt])
def upload_matches(program: str): instructors = fbread.read_instructors(program) institutions = fbread.read_institutions(program) result = iassorter.sort(instructors, institutions) timestamp = str(calendar.timegm(time.gmtime())) db = dfsapi.get_db() json_matches = defaultdict(list) for school in result: for match in result[school]: match_dict = match_to_dict(match) json_matches[school].append(match_dict) db.child(program).child("matches").child(timestamp).child( school).child(match.teacher_name).set(match_dict) return json_matches