-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from pingpingy1/main
[feat] indexHistoryParagraph 실제 데이터 반환
- Loading branch information
Showing
8 changed files
with
506 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from pydantic import BaseModel | ||
from enum import StrEnum | ||
from typing import TypeVar, Generic | ||
|
||
|
||
class GenderType(StrEnum): | ||
male = "남" | ||
female = "여" | ||
|
||
|
||
class FactorType(StrEnum): | ||
gender = "gender" | ||
age = "age" | ||
party = "party" | ||
|
||
|
||
# ============================================== | ||
# = Chart Data Types = | ||
# ============================================== | ||
class GenderChartDataPoint(BaseModel): | ||
gender: GenderType | ||
count: int | ||
|
||
|
||
class AgeChartDataPoint(BaseModel): | ||
minAge: int # 닫힌 구간 | ||
maxAge: int # 열린 구간 | ||
count: int | ||
|
||
|
||
class PartyChartDataPoint(BaseModel): | ||
party: str | ||
count: int | ||
|
||
|
||
T = TypeVar("T", GenderChartDataPoint, AgeChartDataPoint, PartyChartDataPoint) | ||
|
||
|
||
class ChartData(BaseModel, Generic[T]): | ||
data: list[T] | ||
|
||
|
||
# ============================================== | ||
# = Scrap Result Data Types = | ||
# ============================================== | ||
class CouncilType(StrEnum): | ||
local_council = "local_council" | ||
national_council = "national_council" | ||
metropolitan_council = "metropolitan_council" | ||
local_leader = "local_leader" | ||
metro_leader = "metro_leader" | ||
|
||
|
||
class CouncilInfo(BaseModel): | ||
name: str | ||
party: str | ||
|
||
|
||
class ScrapResult(BaseModel): | ||
council_id: str | ||
council_type: CouncilType | ||
councilers: list[CouncilInfo] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from pydantic import BaseModel | ||
|
||
|
||
# ============================================== | ||
# = Template Data Types = | ||
# ============================================== | ||
class GenderTemplateDataMetro(BaseModel): | ||
genderDiversityIndex: float | ||
|
||
|
||
class AgeTemplateDataMetro(BaseModel): | ||
class AgeRankingParagraphData(BaseModel): | ||
class AgeRankingAllIndices(BaseModel): | ||
metroId: int | ||
rank: int | ||
ageDiversityIndex: float | ||
|
||
ageDiversityIndex: float | ||
allIndices: list[AgeRankingAllIndices] | ||
|
||
class AgeIndexHistoryParagraphData(BaseModel): | ||
class AgeIndexHistoryIndexData(BaseModel): | ||
year: int | ||
unit: int | ||
candidateCount: int | ||
candidateDiversityIndex: float | ||
candidateDiversityRank: int | ||
electedDiversityIndex: float | ||
electedDiversityRank: int | ||
|
||
mostRecentYear: int | ||
history: list[AgeIndexHistoryIndexData] | ||
|
||
class AgeHistogramParagraphData(BaseModel): | ||
class AgeHistogramAreaData(BaseModel): | ||
metroId: int | ||
firstQuintile: int | ||
lastQuintile: int | ||
|
||
year: int | ||
candidateCount: int | ||
electedCount: int | ||
firstQuintile: int | ||
lastQuintile: int | ||
divArea: AgeHistogramAreaData | ||
uniArea: AgeHistogramAreaData | ||
|
||
metroId: int | ||
rankingParagraph: AgeRankingParagraphData | ||
indexHistoryParagraph: AgeIndexHistoryParagraphData | ||
ageHistogramParagraph: AgeHistogramParagraphData | ||
|
||
|
||
class PartyTemplateDataMetro(BaseModel): | ||
partyDiversityIndex: float |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.