Skip to content

Commit

Permalink
Merge pull request #56 from NewWays-TechForImpactKAIST/API-model
Browse files Browse the repository at this point in the history
Add API Model
  • Loading branch information
pingpingy1 authored Nov 17, 2023
2 parents 66f3964 + 3df7eaa commit dd8fca9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
32 changes: 32 additions & 0 deletions API/MongoDB.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from dataclasses import dataclass


@dataclass
class Councilor:
sdName: str
sggName: str
wiwName: str
name: str
gender: str
birthday: str
age: int
jobId: int
job: str
eduId: int
edu: str

@classmethod
def from_dict(cls, data: dict):
return cls(
sdName=data.get("sdName"),
sggName=data.get("sggName"),
wiwName=data.get("wiwName"),
name=data.get("name"),
gender=data.get("gender"),
birthday=data.get("birthday"),
age=data.get("age"),
jobId=data.get("jobId"),
job=data.get("job"),
eduId=data.get("eduId"),
edu=data.get("edu"),
)
5 changes: 3 additions & 2 deletions API/candidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import os, requests, sys
import xml.etree.ElementTree as ET
from typing import List
from .MongoDB import Councilor
import argparse

from configurations.secrets import OpenDataPortalSecrets
from .utils import save_to_excel
Expand Down Expand Up @@ -39,11 +41,10 @@ def fetch_data(
data_list = []
for item in root.findall(".//item"):
data_entry = {child.tag: child.text for child in item}

for column in drop_columns:
data_entry.pop(column)

data_list.append(data_entry)
data_list.append(Councilor.from_dict(data_entry))

return data_list

Expand Down

0 comments on commit dd8fca9

Please sign in to comment.