From cb6d9b1d5d80c8a7321900f4c32b82d20fa4408f Mon Sep 17 00:00:00 2001 From: phowell Date: Thu, 29 Aug 2024 10:00:40 -0700 Subject: [PATCH] fix up gott xref --- localcache2.py | 14 ++++++++++++-- pipelines.py | 5 +++-- users.py | 36 ++++++++++++++++++++---------------- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/localcache2.py b/localcache2.py index 008ea33..1ecb47a 100644 --- a/localcache2.py +++ b/localcache2.py @@ -284,7 +284,7 @@ ORDER BY num DESC, u.sortable_name""" % (where1,where2) - +# Fetch the joined courses (one semester) and schedules tables def all_sem_courses_teachers(SEM="202470"): q = f"""SELECT c.id, c.name, c.course_code, u.name, u.sortable_name, u.id AS user_cid, p.sis_user_id, s.type, s.crn FROM canvas.courses AS c JOIN canvas.enrollments AS e ON e.course_id=c.id @@ -364,6 +364,7 @@ def courses_to_sched(): # TODO: fix units when they are variable... change to float in between range. round to 0.5 unit. EXECUTE = 1 + last_time = 0 seasons = {'10':'wi','30':'sp','50':'su','70':'fa'} seasons2 = {'wi':'10', 'sp':'30', 'su':'50', 'fa':'70'} @@ -405,13 +406,22 @@ def courses_to_sched(): try: pod = '' if 'partofday' in c: pod = c['partofday'] + #print(c['cred']) + cred_match = re.search(r'(\d+\.\d+)\-(\d+\.\d+)',c['cred']) + if cred_match: + #print(f"matched range: {cred_match.groups}") + cred_start = float(cred_match.group(1)) + cred_end = float(cred_match.group(2)) + mid = float(int( (cred_end-cred_start)/2 + cred_start )) + c['cred'] = str(mid) + #print(f"middle cred is {c['cred']}") full_sis_code = sis_code+'-'+c['crn'] if full_sis_code in sis_to_sched: q = [sis_to_sched[full_sis_code][0][0], c['crn'], c['code'], c['cred'], c['teacher'], c['start'], c['end'], c['type'], c['loc'], c['site'], pod, int(c['cap']), int(c['act']), sis_code] vals_cache.append( q ) # [ str(x) for x in q ] ) - print(f"{i}: {q}") + #print(f"{i}: {q}") i += 1 if i % 100 == 0: if EXECUTE: diff --git a/pipelines.py b/pipelines.py index aa96852..d023172 100644 --- a/pipelines.py +++ b/pipelines.py @@ -182,7 +182,7 @@ dean['CSIS'] = 'ss' dean['CWE'] = 'ss' dean['DM'] = 'ss' dean['ECOL'] = 'jn' -dean['ECON'] = 'nl' +dean['ECON'] = 'ss' dean['ENGL'] = 'nl' dean['ENGR'] = 'jn' dean['ENVS'] = 'jn' @@ -191,7 +191,7 @@ dean['ETHN'] = 'nl' dean['FRNH'] = 'nl' dean['GEOG'] = 'jn' dean['GEOL'] = 'jn' -dean['GUID'] = 'nl' +dean['GUID'] = 'de' dean['HIST'] = 'nl' dean['HUM'] = 'nl' dean['JOUR'] = 'nl' @@ -219,6 +219,7 @@ dean_names['et'] = 'Enna Trevathan' dean_names['ss'] = 'Susan Sweeney' dean_names['nl'] = 'Noah Lystrup' dean_names['jn'] = 'Jennifer Nari' +dean_names['de'] = 'Diego Espinoza' class FetchError(Exception): diff --git a/users.py b/users.py index 0f8c9f0..7e3c02d 100644 --- a/users.py +++ b/users.py @@ -2234,21 +2234,24 @@ def cross_ref_training(): courses = all_sem_courses_teachers('202470') for c in courses: print(c) - goo = c[6] - crn = c[8] - name = c[1] # full course name - teacher = c[4] # last, first - ctype = c[7] - dept1 = re.search(r'([A-Z]+)(\d+)',c[2].split(' ')[0]).group(1) - alldepts.add(dept1) - d = list(c) - #d.append(ctype) - if not ctype: - print(f"not finding mode for {name}") - continue - if ctype=='in-person': continue - teachers[teacher].append(d) - teachers_bydept[dept1].add(teacher) + try: + goo = c[6] + crn = c[8] + name = c[1] # full course name + teacher = c[4] # last, first + ctype = c[7] + dept1 = re.search(r'([A-Z]+)(\d+)',c[2].split(' ')[0]).group(1) + alldepts.add(dept1) + d = list(c) + #d.append(ctype) + if not ctype: + print(f"not finding mode for {name}") + continue + if ctype=='in-person': continue + teachers[teacher].append(d) + teachers_bydept[dept1].add(teacher) + except: + print(f"Problem with {c}, skipping") alldepts = list(alldepts) alldepts.sort() @@ -2259,7 +2262,7 @@ def cross_ref_training(): deptfont = Font(bold=True) flagfont = PatternFill("solid", fgColor="00FFFFCC") - for thedean in ['et','nl','ss','jn']: + for thedean in ['et','nl','ss','jn', 'de']: sheet.cell(row=r, column=1).value = dean_names[thedean] sheet.cell(row=r, column=1).font = deptfont r += 2 @@ -2542,6 +2545,7 @@ if __name__ == "__main__": #22: ['Sync personnel and conference user databases', user_db_sync], 23: ['Find non-gnumbers', find_no_goo ], 24: ['compare user tables', compare_db_tables], + 25: ['cross ref training', cross_ref_training], 26: ['find goo numbers in training spreadsheet', training_find_goos], #3: ['Main index, 1 year, teachers and their classes', getAllTeachersInTerm],