Skip to content

Commit

Permalink
Add: Chart Data year
Browse files Browse the repository at this point in the history
  • Loading branch information
happycastle114 committed Nov 30, 2023
1 parent 2bb5fb0 commit cda1fcc
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions routers/scrapResultNational.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ async def getNationalTemplateData(

@router.get("/chart-data")
async def getNationalChartData(
factor: FactorType,
factor: FactorType, year: int = 2020
) -> ErrorResponse | ChartData[GenderChartDataPoint] | ChartData[
AgeChartDataPoint
] | ChartData[PartyChartDataPoint]:
Expand All @@ -328,11 +328,10 @@ async def getNationalChartData(
{
"councilorType": "national_councilor",
"level": 0,
"year": year,
"is_elected": True,
}
)
.sort({"year": -1})
.limit(1)
.to_list(5)
)[0]

Expand All @@ -354,10 +353,9 @@ async def getNationalChartData(
"level": 0,
"is_elected": True,
"method": "equal",
"year": year,
}
)
.sort({"year": -1})
.limit(1)
.to_list(5)
)[0]
age_list = [
Expand Down Expand Up @@ -385,10 +383,9 @@ async def getNationalChartData(
"councilorType": "national_councilor",
"level": 0,
"is_elected": True,
"year": year,
}
)
.sort({"year": -1})
.limit(1)
.to_list(5)
)[0]
return ChartData[PartyChartDataPoint].model_validate(
Expand Down

0 comments on commit cda1fcc

Please sign in to comment.