diff --git a/API/__init__.py b/API/__init__.py index 9c71e90..273109f 100644 --- a/API/__init__.py +++ b/API/__init__.py @@ -20,10 +20,17 @@ "10": "교육의원", "11": "교육감", } -SG_TYPECODE_TYPE = { +ELECTED_TYPECODE_TYPE = { "2": CouncilType.NATIONAL_COUNCIL, "3": CouncilType.METRO_LEADER, "4": CouncilType.LOCAL_LEADER, "5": CouncilType.METROPOLITAN_COUNCIL, "6": CouncilType.LOCAL_COUNCIL, + "9": CouncilType.LOCAL_COUNCIL, +} +CANDIDATE_TYPECODE_TYPE = { + "2": CouncilType.NATIONAL_COUNCIL_CAND, + "5": CouncilType.METROPOLITAN_COUNCIL_CAND, + "6": CouncilType.LOCAL_COUNCIL_CAND, + "9": CouncilType.LOCAL_COUNCIL_CAND, } diff --git a/API/candidate.py b/API/candidate.py index d193c3d..505df9c 100644 --- a/API/candidate.py +++ b/API/candidate.py @@ -7,6 +7,7 @@ from configurations.secrets import OpenDataPortalSecrets from .utils import save_to_excel, save_to_mongo, getLocalMetroMap +from . import SG_TYPECODE, CANDIDATE_TYPECODE_TYPE BASE_URL = "http://apis.data.go.kr/9760000/PofelcddInfoInqireService/getPofelcddRegistSttusInfoInqire" @@ -88,4 +89,4 @@ def fetch_all_data( if args.save_method == "excel": save_to_excel(data_list, args.sgTypecode, is_elected=False) elif args.save_method == "mongo": - save_to_mongo(data_list, args.sgTypecode, "local_councilor_cand") + save_to_mongo(data_list, args.sgTypecode, CANDIDATE_TYPECODE_TYPE[args.sgTypecode]) diff --git a/API/elected.py b/API/elected.py index 93528b0..635efbf 100644 --- a/API/elected.py +++ b/API/elected.py @@ -7,6 +7,7 @@ from configurations.secrets import OpenDataPortalSecrets from .utils import save_to_excel, save_to_mongo, getLocalMetroMap +from . import SG_TYPECODE, ELECTED_TYPECODE_TYPE BASE_URL = "http://apis.data.go.kr/9760000/WinnerInfoInqireService2/getWinnerInfoInqire" @@ -85,4 +86,4 @@ def fetch_all_data( if args.save_method == "excel": save_to_excel(data_list, args.sgTypecode, is_elected=True) elif args.save_method == "mongo": - save_to_mongo(data_list, args.sgTypecode, "local_councilor") + save_to_mongo(data_list, args.sgTypecode, ELECTED_TYPECODE_TYPE[args.sgTypecode]) diff --git a/API/utils.py b/API/utils.py index c8d685f..1800f98 100644 --- a/API/utils.py +++ b/API/utils.py @@ -3,7 +3,7 @@ import pandas as pd from typing import List, Optional, Dict -from . import BASE_DIR, SG_TYPECODE, SG_TYPECODE_TYPE +from . import BASE_DIR, SG_TYPECODE from configurations.secrets import MongoDBSecrets from db.client import client from API.MongoDB import Councilor diff --git a/db/types.py b/db/types.py index 7e22fdd..c65711c 100644 --- a/db/types.py +++ b/db/types.py @@ -10,8 +10,14 @@ class CouncilType(str, Enum): """ LOCAL_COUNCIL = "local_councilor" + LOCAL_COUNCIL_CAND = "local_councilor_candidate" + NATIONAL_COUNCIL = "national_councilor" + NATIONAL_COUNCIL_CAND = "national_councilor_candidate" + METROPOLITAN_COUNCIL = "metropolitan_councilor" + METROPOLITAN_COUNCIL_CAND = "metropolitan_councilor_candidate" + LOCAL_LEADER = "local_leader" METRO_LEADER = "metro_leader" """