Skip to content

Commit

Permalink
Merge pull request #336 from City-of-Turku/bugfix/eco-counter-traffic…
Browse files Browse the repository at this point in the history
…-counter-handle-year-change

Bugfix/eco counter traffic counter handle year change
  • Loading branch information
juuso-j authored Mar 28, 2024
2 parents bb83843 + 4b7b11e commit 7bd5482
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion eco_counter/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import platform
import types
from datetime import datetime

import requests
from django.conf import settings
Expand All @@ -12,7 +13,7 @@
# Manually define the end year, as the source data comes from the page
# defined in env variable TRAFFIC_COUNTER_OBSERVATIONS_BASE_URL.
# Change end year when data for the next year is available.
TRAFFIC_COUNTER_END_YEAR = 2023
TRAFFIC_COUNTER_END_YEAR = datetime.today().year
ECO_COUNTER_START_YEAR = 2020
LAM_COUNTER_START_YEAR = 2010
TELRAAM_COUNTER_START_YEAR = 2023
Expand Down
5 changes: 4 additions & 1 deletion eco_counter/management/commands/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,10 @@ def get_traffic_counter_csv(start_year=2015):
# data from years before the start year.
if key <= start_year:
continue
concat_df = get_dataframe(TRAFFIC_COUNTER_CSV_URLS[key])
try:
concat_df = get_dataframe(TRAFFIC_COUNTER_CSV_URLS[key])
except AssertionError:
continue
# ignore_index=True, do not use the index values along the concatenation axis.
# The resulting axis will be labeled 0, …, n - 1.
df = pd.concat([df, concat_df], ignore_index=True)
Expand Down

0 comments on commit 7bd5482

Please sign in to comment.