Skip to content

Commit 0238411

Browse files
committed
DBC22-1811: added CARS data to events table
1 parent e108aa3 commit 0238411

File tree

6 files changed

+100
-15
lines changed

6 files changed

+100
-15
lines changed

src/backend/apps/event/enums.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ class EVENT_DIRECTION:
9292
EVENT_DIRECTION.EAST: "Eastbound",
9393
EVENT_DIRECTION.SOUTH: "Southbound",
9494
EVENT_DIRECTION.WEST: "Westbound",
95-
EVENT_DIRECTION.BOTH: "Both Directions",
96-
EVENT_DIRECTION.NONE: "Not Applicable"
95+
EVENT_DIRECTION.BOTH: "Both",
96+
EVENT_DIRECTION.NONE: "Both"
9797
}
9898

9999
EVENT_DIFF_FIELDS = [

src/backend/apps/event/serializers.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,38 @@ class ScheduleSerializer(serializers.Serializer):
1717
)
1818

1919

20+
def tail_trim(text, target):
21+
target_index = text.find(target)
22+
return text[:target_index] if target_index != -1 else text
23+
24+
25+
def optimize_description(text):
26+
res = text
27+
28+
# Remove next update from the end
29+
res = tail_trim(res, ' Next update')
30+
31+
# Remove last updated from the end
32+
res = tail_trim(res, ' Last updated')
33+
34+
# Split by periods and remove road+directions
35+
res = res.split('. ')[1:]
36+
37+
# Remove 'at' location phrases from the beginning
38+
res[0] = tail_trim(res[0], ' at')
39+
40+
# Remove 'between' location phrases from the beginning
41+
res[0] = tail_trim(res[0], ' between')
42+
43+
# Join split strings and return
44+
return '. '.join(res) if len(res) > 1 else res[0] + '.'
45+
46+
2047
class EventInternalSerializer(serializers.ModelSerializer):
2148
display_category = serializers.SerializerMethodField()
2249
direction_display = serializers.SerializerMethodField()
2350
route_display = serializers.SerializerMethodField()
51+
optimized_description = serializers.SerializerMethodField()
2452
schedule = ScheduleSerializer()
2553

2654
class Meta:
@@ -50,11 +78,14 @@ def get_route_display(self, obj):
5078

5179
return res
5280

81+
def get_optimized_description(self, obj):
82+
return optimize_description(obj.description)
83+
5384
def get_display_category(self, obj):
5485
if obj.closed:
5586
return EVENT_DISPLAY_CATEGORY.CLOSURE
5687

57-
if obj.id.startswith('drivebc.ca/DBCRCON'):
88+
if obj.id.startswith('DBCRCON'):
5889
return EVENT_DISPLAY_CATEGORY.ROAD_CONDITION
5990

6091
if obj.start and datetime.datetime.now(pytz.utc) < obj.start:

src/frontend/src/App.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,9 @@ body {
139139
&::placeholder {
140140
color: $Type-Disabled;
141141
}
142-
}
142+
}
143+
144+
// Hide recaptcha badge
145+
.grecaptcha-badge {
146+
visibility: hidden !important;
147+
}

src/frontend/src/Components/events/EventCard.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,37 @@ export default function EventCard(props) {
3535
</div>
3636
</div>
3737

38+
<div className="location">
39+
<div className="header">{ showLoader ? <Skeleton /> : 'Location' }</div>
40+
<div className="content">{ showLoader ? <Skeleton width={200} /> : event.location_description }</div>
41+
</div>
42+
43+
<div className="closest-landmark">
44+
<div className="header">{ showLoader ? <Skeleton /> : 'Closest Landmark' }</div>
45+
<div className="content">
46+
{ showLoader ? <Skeleton width={100} /> : (event.closest_landmark ? event.closest_landmark : '-')}
47+
</div>
48+
</div>
49+
3850
<div className="description">
3951
<div className="header">{ showLoader ? <Skeleton /> : 'Description' }</div>
4052
<div className="content">{ showLoader ? <Skeleton count={7} /> : event.description }</div>
4153
</div>
4254

4355
<div className="last-update">
44-
<div className="header">{ showLoader ? <Skeleton /> : 'Last Update' }</div>
56+
<div className="header">{ showLoader ? <Skeleton /> : 'Last Updated' }</div>
4557
<div className="content">
4658
{ showLoader ? <Skeleton width={'90%'} /> : <FriendlyTime date={event.last_updated} /> }
4759
</div>
4860
</div>
4961

62+
<div className="next-update">
63+
<div className="header">{ showLoader ? <Skeleton /> : 'Next Update' }</div>
64+
<div className="content">
65+
{ showLoader ? <Skeleton width={'90%'} /> : <FriendlyTime date={event.next_update} /> }
66+
</div>
67+
</div>
68+
5069
<div className="map">
5170
<div className="header">{ showLoader ? <Skeleton /> : 'Map' }</div>
5271
<div className="content">

src/frontend/src/Components/events/EventsTable.scss

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,22 +89,34 @@ td.last_updated .friendly-time-text {
8989
}
9090

9191
&.route_at {
92-
width: 8.5614%
92+
width: 8.7677%
9393
}
9494

95-
&.direction {
96-
width: 8.1593%
95+
&.direction_display {
96+
width: 10.1058%
9797
}
9898

99-
&.description {
100-
width: 50.1690%
99+
&.location_description {
100+
width: 11.3612%
101+
}
102+
103+
&.closest_landmark {
104+
width: 10.5925%
105+
}
106+
107+
&.optimized_description {
108+
width: 19.9172%
101109
}
102110

103111
&.last_updated {
104-
width: 12.9110%
112+
width: 10.5293%
113+
}
114+
115+
&.next_update {
116+
width: 8.5266%
105117
}
106118

107119
&.map {
108-
width: 5.4422%
120+
width: 5.4439%
109121
}
110122
}

src/frontend/src/pages/EventsListPage.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,25 @@ export default function EventsListPage() {
8282
},
8383
{
8484
header: 'Direction',
85-
accessorKey: 'direction',
86-
cell: (props) => <span>{props.getValue().toLowerCase()}</span>,
85+
accessorKey: 'direction_display',
86+
cell: (props) => <span>{props.getValue()}</span>,
87+
enableSorting: false,
88+
},
89+
{
90+
header: 'Location',
91+
accessorKey: 'location_description',
92+
cell: (props) => <span>{props.getValue()}</span>,
93+
enableSorting: false,
94+
},
95+
{
96+
header: 'Closest Landmark',
97+
accessorKey: 'closest_landmark',
98+
cell: (props) => <span>{props.getValue() ? props.getValue() : '-'}</span>,
8799
enableSorting: false,
88100
},
89101
{
90102
header: 'Description',
91-
accessorKey: 'description',
103+
accessorKey: 'optimized_description',
92104
enableSorting: false,
93105
},
94106
{
@@ -97,6 +109,12 @@ export default function EventsListPage() {
97109
cell: (props) => <FriendlyTime date={props.getValue()} />,
98110
sortDescFirst: true,
99111
},
112+
{
113+
header: 'Next Update',
114+
accessorKey: 'next_update',
115+
cell: (props) => props.getValue() ? <FriendlyTime date={props.getValue()} /> : '-',
116+
enableSorting: false,
117+
},
100118
{
101119
header: 'Map',
102120
accessorKey: 'map',

0 commit comments

Comments
 (0)