Skip to content

DBC22-1815: road conditions are no longer mapped by subtype #301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions src/backend/apps/event/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ class EVENT_SUB_TYPE:
PARTLY_SNOW_PACKED = "PARTLY_SNOW_PACKED"
MUD = "MUD"
PLANNED_EVENT = "PLANNED_EVENT"
POOR_VISIBILITY = "POOR_VISIBILITY"
POOR_VISIBILITY = "POOR_VISIBILITY"
PARTLY_SNOW_COVERED = "PARTLY_SNOW_COVERED"
DRIFTING_SNOW = "DRIFTING_SNOW"
PASSABLE_WITH_CARE = "PASSABLE_WITH_CARE"



EVENT_SUB_TYPE_CHOICES = (
(EVENT_SUB_TYPE.ALMOST_IMPASSABLE, "Almost Impassable"),
(EVENT_SUB_TYPE.FIRE, "Fire"),
Expand Down Expand Up @@ -127,17 +126,3 @@ class EVENT_DISPLAY_CATEGORY:
FUTURE_DELAYS = 'futureEvents'
ROAD_CONDITION = 'roadConditions'
HIGHWAY_CAMERAS = 'highwayCams'


EVENT_DISPLAY_CATEGORY_MAP = {
# Only road conditions are directly mapped currently
EVENT_SUB_TYPE.POOR_VISIBILITY: EVENT_DISPLAY_CATEGORY.ROAD_CONDITION,
EVENT_SUB_TYPE.PARTLY_ICY: EVENT_DISPLAY_CATEGORY.ROAD_CONDITION,
EVENT_SUB_TYPE.ICE_COVERED: EVENT_DISPLAY_CATEGORY.ROAD_CONDITION,
EVENT_SUB_TYPE.SNOW_PACKED: EVENT_DISPLAY_CATEGORY.ROAD_CONDITION,
EVENT_SUB_TYPE.PARTLY_SNOW_PACKED: EVENT_DISPLAY_CATEGORY.ROAD_CONDITION,
EVENT_SUB_TYPE.PARTLY_SNOW_COVERED: EVENT_DISPLAY_CATEGORY.ROAD_CONDITION,
EVENT_SUB_TYPE.DRIFTING_SNOW: EVENT_DISPLAY_CATEGORY.ROAD_CONDITION,
EVENT_SUB_TYPE.ALMOST_IMPASSABLE: EVENT_DISPLAY_CATEGORY.ROAD_CONDITION,
EVENT_SUB_TYPE.PASSABLE_WITH_CARE: EVENT_DISPLAY_CATEGORY.ROAD_CONDITION,
}
5 changes: 2 additions & 3 deletions src/backend/apps/event/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from apps.event.enums import (
EVENT_DIRECTION_DISPLAY,
EVENT_DISPLAY_CATEGORY,
EVENT_DISPLAY_CATEGORY_MAP,
EVENT_SEVERITY,
)
from apps.event.models import Event
Expand Down Expand Up @@ -55,8 +54,8 @@ def get_display_category(self, obj):
if obj.closed:
return EVENT_DISPLAY_CATEGORY.CLOSURE

if obj.event_sub_type in EVENT_DISPLAY_CATEGORY_MAP:
return EVENT_DISPLAY_CATEGORY_MAP[obj.event_sub_type]
if obj.id.startswith('drivebc.ca/DBCRCON'):
return EVENT_DISPLAY_CATEGORY.ROAD_CONDITION

if obj.start and datetime.datetime.now(pytz.utc) < obj.start:
return EVENT_DISPLAY_CATEGORY.FUTURE_DELAYS
Expand Down
10 changes: 7 additions & 3 deletions src/backend/apps/feed/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
EventRoadsField,
FerryGeographyField,
FerryPropertiesField,
RegionalWeatherPropertiesField,
WebcamHighwayField,
WebcamImageStatsField,
WebcamLocationField,
WebcamRegionField,
WebcamRegionGroupField,
RegionalWeatherPropertiesField,
)
from rest_framework import serializers
from apps.weather.models import RegionalWeather
from rest_framework import serializers


# Webcam
Expand Down Expand Up @@ -161,12 +161,16 @@ class FerryFeedSerializer(serializers.Serializer):
class FerryAPISerializer(serializers.Serializer):
features = FerryFeedSerializer(many=True)


# Regional Weather
class RegionalWeatherFeedSerializer(serializers.Serializer):
properties = RegionalWeatherPropertiesField(source="*")


class RegionalWeatherAPISerializer(serializers.Serializer):
features = RegionalWeatherFeedSerializer(many=True)


class RegionalWeatherSerializer(serializers.Serializer):
class Meta:
model = RegionalWeather
Expand All @@ -184,4 +188,4 @@ class Meta:
'conditions',
'forecast_group',
'hourly_forecast_group',
)
)