Skip to content

fix fetch_union_members() - #346

Merged
petrCher merged 2 commits into
mainfrom
unimem_fields_fix
Apr 18, 2026
Merged

fix fetch_union_members()#346
petrCher merged 2 commits into
mainfrom
unimem_fields_fix

Conversation

@RedstoneEnjoyer

Copy link
Copy Markdown
Collaborator

Ручка на которую ориентровались при подгрузке полей из API содержит не полный их набор. Добавил апдейт словаря ключей (т.е. полей) со второй ручки чтобы ниче не терять

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the fetch_union_members() staging DAG to pull a fuller set of user fields by merging the per-user /api/auth/users/{id} response into each user record, addressing missing fields from the list endpoint.

Changes:

  • Replaced per-field assignments from the per-user endpoint with a blanket dict.update() merge into the user record.
  • Added a comment clarifying overwrite behavior when keys collide.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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)

Copilot AI Apr 18, 2026

Copy link

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 (и при необходимости удалить исходный ключ).

Suggested change
user.update(resp_student_id_dict)
user.update(resp_student_id_dict)
if "faculty_title_eng" in user:
user["faculty_translated"] = user["faculty_title_eng"]
del user["faculty_title_eng"]

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сука ты прав .. ты не такой осел как я думал. Исправлено, давай аппурв

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)

Copilot AI Apr 18, 2026

Copy link

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) безусловно перезаписывает уже полученные из /api/auth/users/?status=MEMBER значения, включая случаи когда во втором ответе поле присутствует, но равно null/пустое. Это противоречит цели «ничего не терять» и может ухудшить качество данных. Более безопасный вариант — обновлять только отсутствующие ключи или обновлять только ключи с непустыми значениями (или явно перечислить поля, которые нужно брать со второго endpoint).

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вот давай проверим сначала будут там нуллы или нет пидр. Вторая ручка это по сути те же значения с первой только с дополнительными полями че ты мне тут рассказываешь откуда там бл внезапно магически появятся нуллы а

@petrCher
petrCher merged commit a33b9e8 into main Apr 18, 2026
2 checks passed
@petrCher
petrCher deleted the unimem_fields_fix branch April 18, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants