Repository navigation
fix fetch_union_members() #346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,12 +94,9 @@ def fetch_union_members(): | |
| try: | ||
| resp_student_id_dict = resp_student_id.json() | ||
| logging.info(f"Available fields for user {user['id']}: {list(resp_student_id_dict.keys())}") | ||
| user["faculty_translated"] = resp_student_id_dict["faculty_title_eng"] | ||
| user["first_name_translated"] = resp_student_id_dict["first_name_translated"] | ||
| user["last_name_translated"] = resp_student_id_dict["last_name_translated"] | ||
| user["middle_name"] = resp_student_id_dict["middle_name"] | ||
| user["middle_name_translated"] = resp_student_id_dict["middle_name_translated"] | ||
| user["student_id"] = resp_student_id_dict["student_id"] | ||
| # Если ключи одинаковые то значения будут перезаписаны по новому источнику | ||
| user.update(resp_student_id_dict) | ||
|
||
| user["faculty_translated"] = user.get("faculty_title_eng") | ||
| except Exception as e: | ||
| logging.error(f"Failed to fetch data from lk.msuprof.com for user {user['id']}: {str(e)}") | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Замена явного маппинга на
user.update(resp_student_id_dict)меняет имена полей в результирующей записи. Раньше значениеresp_student_id_dict["faculty_title_eng"]сохранялось вuser["faculty_translated"], а теперь в таблицу уйдёт колонкаfaculty_title_eng(и колонкаfaculty_translatedможет пропасть). Это, как минимум, ломает downstream SQL, где используетсяfaculty_translated(см.dags/ods/user/info.sql). Решение: сохранить обратную совместимость — либо продолжать маппитьfaculty_title_eng -> faculty_translated, либо послеupdate()явно проставлятьfaculty_translatedизfaculty_title_eng(и при необходимости удалить исходный ключ).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Сука ты прав .. ты не такой осел как я думал. Исправлено, давай аппурв