Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/48-mongodb-update' into 48-mongo…
Browse files Browse the repository at this point in the history
…db-update
  • Loading branch information
keonly committed Nov 13, 2023
2 parents 558aefb + c26c0fd commit ab3498c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion API/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
"4": CouncilType.LOCAL_LEADER,
"5": CouncilType.METROPOLITAN_COUNCIL,
"6": CouncilType.LOCAL_COUNCIL,
}
}
6 changes: 5 additions & 1 deletion API/candidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
BASE_URL = "http://apis.data.go.kr/9760000/PofelcddInfoInqireService/getPofelcddRegistSttusInfoInqire"


def fetch_data(sgId: str, sgTypecode: str, page_no: int = 1, num_of_rows: int = 10_000) -> List[dict]:
def fetch_data(
sgId: str, sgTypecode: str, page_no: int = 1, num_of_rows: int = 10_000
) -> List[dict]:
params = {
"serviceKey": OpenDataPortalSecrets.service_key,
"pageNo": str(page_no),
Expand All @@ -37,6 +39,7 @@ def fetch_data(sgId: str, sgTypecode: str, page_no: int = 1, num_of_rows: int =

return data_list


def fetch_all_data(sgIds: List[str], sgTypecodes: List[str]) -> List[dict]:
data_list = []
for sgId in sgIds:
Expand All @@ -45,6 +48,7 @@ def fetch_all_data(sgIds: List[str], sgTypecodes: List[str]) -> List[dict]:

return data_list


if __name__ == "__main__":
sgTypecode_input = input("원하는 sgTypecode 하나를 입력하세요:\n")
sgIds_input = input("원하는 sgId를 입력하세요. 여러 개라면 ','로 구분하여 입력하세요:\n").split(",")
Expand Down
4 changes: 3 additions & 1 deletion API/elected.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
BASE_URL = "http://apis.data.go.kr/9760000/WinnerInfoInqireService2/getWinnerInfoInqire"


def fetch_data(sgId: str, sgTypecode: str, page_no: int = 1, num_of_rows: int = 10_000) -> List[dict]:
def fetch_data(
sgId: str, sgTypecode: str, page_no: int = 1, num_of_rows: int = 10_000
) -> List[dict]:
params = {
"serviceKey": OpenDataPortalSecrets.service_key,
"pageNo": str(page_no),
Expand Down
2 changes: 1 addition & 1 deletion API/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ def save_to_mongo(data: List[dict], sgTypecode: str) -> None:
# TODO: 지역구별로 분리하여 업데이트하는 로직 추가
collection.insert_many(data)

print(f"데이터를 MongoDB의 '{collection_name}' 컬렉션에 저장하였습니다.")
print(f"데이터를 MongoDB의 '{collection_name}' 컬렉션에 저장하였습니다.")
4 changes: 1 addition & 3 deletions API/votecode.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
if args.code:
formatted_code = ", ".join([f"({k}) {v}" for k, v in SG_TYPECODE.items()])
print(formatted_code)
print(
"sgTypecode를 입력하면 해당 sgTypecode와 일치하는 sgId 값을 출력합니다. 여러 개를 입력하려면 ','로 구분해 주세요."
)
print("sgTypecode를 입력하면 해당 sgTypecode와 일치하는 sgId 값을 출력합니다. 여러 개를 입력하려면 ','로 구분해 주세요.")

url = "http://apis.data.go.kr/9760000/CommonCodeService/getCommonSgCodeList"
params = {
Expand Down

0 comments on commit ab3498c

Please sign in to comment.