Skip to content

Commit ac498d7

Browse files
committed
Store results from GTED in Crosswalk
1 parent d6a3ae5 commit ac498d7

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

checkpoint.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,30 @@ def search_gted(**kwargs: str) -> List[Dict[str, Any]]:
219219
)
220220
buzzapi_response.raise_for_status()
221221

222-
# TODO store results in Crosswalk # pylint: disable=fixme
222+
for account in buzzapi_response.json()["api_result_data"]:
223+
db().execute(
224+
(
225+
"INSERT INTO crosswalk (gt_person_directory_id, gtid, primary_username)"
226+
" VALUES (:gt_person_directory_id, :gtid, :primary_username) ON CONFLICT DO NOTHING" # noqa
227+
),
228+
{
229+
"gt_person_directory_id": account["gtPersonDirectoryId"],
230+
"gtid": account["gtGTID"],
231+
"primary_username": account["gtPrimaryGTAccountUsername"],
232+
},
233+
)
234+
db().execute(
235+
(
236+
"INSERT INTO crosswalk_email_address (email_address, gt_person_directory_id)" # noqa
237+
" VALUES (:email_address, :gt_person_directory_id)"
238+
" ON CONFLICT DO UPDATE SET gt_person_directory_id = (:gt_person_directory_id) WHERE email_address = (:email_address)"
239+
# noqa
240+
),
241+
{
242+
"email_address": account["mail"],
243+
"gt_person_directory_id": account["gtPersonDirectoryId"],
244+
},
245+
)
223246

224247
return buzzapi_response.json()["api_result_data"] # type: ignore
225248

0 commit comments

Comments
 (0)