Skip to content

Commit

Permalink
Merge pull request #223 from City-of-Turku/develop
Browse files Browse the repository at this point in the history
Production update
  • Loading branch information
juuso-j authored Jan 26, 2023
2 parents 691df71 + 7588605 commit 42ad46d
Show file tree
Hide file tree
Showing 29 changed files with 13,426 additions and 148 deletions.
16 changes: 8 additions & 8 deletions config_dev.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ MOBILITY_DATA_CHARGING_STATIONS_URL=https://services1.arcgis.com/rhs5fjYxdOG1Et6
MOBILITY_DATA_GAS_FILLING_STATIONS_URL=https://services1.arcgis.com/rhs5fjYxdOG1Et61/ArcGIS/rest/services/ChargingStations/FeatureServer/0/query?f=json&where=1%20%3D%201%20OR%201%20%3D%201&returnGeometry=true&spatialRel=esriSpatialRelIntersects&outFields=LOCATION_ID%2CNAME%2CADDRESS%2CURL%2COBJECTID%2CTYPE
MOBILITY_DATA_GEOMETRY_URL=https://tie.digitraffic.fi/api/v3/data/traffic-messages/area-geometries?id=11&lastUpdated=false
# Environment variables required for importing street maintenance history.
AUTORI_SCOPE=
AUTORI_CLIENT_ID=
AUTORI_CLIENT_SECRET=
AUTORI_EVENTS_URL=https://api.autori.io/api/dailymaintenance-a3/route/types/operation/
AUTORI_ROUTES_URL=https://api.autori.io/api/dailymaintenance-a3/route/
AUTORI_VEHICLES_URL=https://api.autori.io/api/dailymaintenance-a3/route/types/vehicle/
AUTORI_CONTRACTS_URL=https://api.autori.io/api/dailymaintenance-a3/contracts/
AUTORI_TOKEN_URL=https://login.microsoftonline.com/86792d09-0d81-4899-8d66-95dfc96c8014/oauth2/v2.0/token?Scope=api://7f45c30e-cc67-4a93-85f1-0149b44c1cdf/.default
YIT_SCOPE=
YIT_CLIENT_ID=
YIT_CLIENT_SECRET=
YIT_EVENTS_URL=https://api.autori.io/api/dailymaintenance-a3/route/types/operation/
YIT_ROUTES_URL=https://api.autori.io/api/dailymaintenance-a3/route/
YIT_VEHICLES_URL=https://api.autori.io/api/dailymaintenance-a3/route/types/vehicle/
YIT_CONTRACTS_URL=https://api.autori.io/api/dailymaintenance-a3/contracts/
YIT_TOKEN_URL=https://login.microsoftonline.com/86792d09-0d81-4899-8d66-95dfc96c8014/oauth2/v2.0/token?Scope=api://7f45c30e-cc67-4a93-85f1-0149b44c1cdf/.default
KUNTEC_KEY=
21 changes: 16 additions & 5 deletions eco_counter/management/commands/import_counter_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,17 +264,29 @@ def save_observations(
year_has_changed = False
changed_daylight_saving_to_summer = False
# All Hourly, daily and weekly data that are past the current_week_number
# are delete thus they are repopulated. HourData and DayData are deleted
# are delete thus they are repopulated. HourData and DayData are deleted
# thus their on_delete is set to models.CASCADE.
Day.objects.filter(
month__month_number=current_month_number,
month__year__year_number=current_year_number,
station__csv_data_source=csv_data_source,
).delete()
for week_number in range(current_week_number + 1, current_week_number + 5):
# If week number >= 52 then do not delete the week as it has been created
# in the previous year.
if current_week_number >= 52:
# Set to 0 as we want to delete the first week, as it is not the first week
# of the year if week number is >=52.
start_week_number = 0
else:
# Add by one, i.e., do not delete the current_week.
start_week_number = current_week_number + 1

for week_number in range(start_week_number, start_week_number + 5):
Week.objects.filter(
week_number=week_number, years__year_number=current_year_number
week_number=week_number,
years__year_number=current_year_number,
station__csv_data_source=csv_data_source,
).delete()

# Set the references to the current state.
for station in stations:
current_years[station] = Year.objects.get_or_create(
Expand Down Expand Up @@ -592,7 +604,6 @@ def handle(self, *args, **options):
elif counter == TRAFFIC_COUNTER:
csv_data = get_traffic_counter_csv(
start_year=import_state.current_year_number
# start_year=2022
)
start_time = "{year}-{month}-1T00:00".format(
year=import_state.current_year_number,
Expand Down
13 changes: 13 additions & 0 deletions mobility_data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,24 @@ To import data type:
### Crosswalk signs
```
./manage.py import_wfs CrossWalkSign
```
### Disabled parking signs
```
./manage.py import_wfs DisabledParkingSign
```

### Föli stops
```
./manage.py import_foli_stops
```

### Outdoor gym devices
Imports the outdoor gym devices from the services.unit model. i.e., sets references by id to the services.unit model. The data is then serialized from the services.unit model.
```
./manage.py import_outdoor_gym_devices
```

## Deletion
To delete mobile units for a content type.
```
Expand Down
Loading

0 comments on commit 42ad46d

Please sign in to comment.