Skip to content

Commit

Permalink
Fix: Year
Browse files Browse the repository at this point in the history
  • Loading branch information
happycastle114 committed Nov 30, 2023
1 parent 9594569 commit 2bb5fb0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions routers/scrapResultNational.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,16 @@ async def getNationalTemplateData(
)
years.sort()
assert len(years) >= 2

year_index = years.index(year)
if year_index == 0:
return NO_DATA_ERROR_RESPONSE

current_elected = client.stats_db["party_hist"].find(
{
"councilorType": "national_councilor",
"level": 0,
"is_elected": True,
"year": years[-1],
"year": years[year_index],
},
{
"_id": 0,
Expand All @@ -263,7 +266,7 @@ async def getNationalTemplateData(
"councilorType": "national_councilor",
"level": 0,
"is_elected": False,
"year": years[-1],
"year": years[year_index],
},
{
"_id": 0,
Expand All @@ -278,7 +281,7 @@ async def getNationalTemplateData(
"councilorType": "national_councilor",
"level": 0,
"is_elected": True,
"year": years[-2],
"year": years[year_index - 1],
},
{
"_id": 0,
Expand Down

0 comments on commit 2bb5fb0

Please sign in to comment.