Skip to content

Commit

Permalink
feat(add) global candidate
Browse files Browse the repository at this point in the history
  • Loading branch information
happycastle114 committed Nov 27, 2023
1 parent 9dd3c7a commit f5389de
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions API/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"8": CouncilType.METROPOLITAN_COUNCIL,
"9": CouncilType.LOCAL_COUNCIL,
}

CANDIDATE_TYPECODE_TYPE = {
"2": CouncilType.NATIONAL_COUNCIL_CAND,
# "3": CouncilType.METRO_LEADER_CAND,
Expand Down
14 changes: 13 additions & 1 deletion API/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def save_to_mongo(data: List[dict], sgTypecode: str, where: str) -> None:
main_collection = db[where]

# TODO: Support other types of councils
if sgTypecode in ["8", "5", "2", "7", "6", "9"]:
if sgTypecode in ["8", "5", "2","6", "9"]:
for entry in data:
entry["wiwName"] = change_local_name(entry["sdName"], entry["wiwName"])
district_id = get_district_id(entry["sdName"], entry["wiwName"])
Expand All @@ -60,6 +60,18 @@ def save_to_mongo(data: List[dict], sgTypecode: str, where: str) -> None:
print(
f"Warning: '{entry['sdName']} {entry['wiwName']}'에 해당하는 지역 ID가 존재하지 않습니다."
)
elif sgTypecode in ["7"]:
for entry in data:

main_collection.update_one(
{
"name": entry["name"],
"localId": 0,
"metroId": 0,
},
{"$set": Councilor.from_dict(entry).to_dict()},
upsert=True,
)
else:
raise NotImplementedError("현재 구시군의회의원(6) 및 기초의원비례대표(9)만 구현되어 있습니다.")

Expand Down

0 comments on commit f5389de

Please sign in to comment.