Skip to content

Commit 19c60cc

Browse files
committed
feat(alerts-reducer): filter out TRAMS alerts for MTC
1 parent 729a05c commit 19c60cc

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

lib/alerts/reducers/alerts.js

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -91,55 +91,55 @@ const alerts = (state = defaultState, action) => {
9191
}
9292
}
9393
}
94-
const allAlerts = action.rtdAlerts ? action.rtdAlerts.map((rtdAlert) => {
95-
// let activeIndex = action.projects.findIndex(p => p.id == config.activeProjectId)
96-
const project = action.activeProject // action.projects[activeIndex]
94+
const allAlerts = action.rtdAlerts ? action.rtdAlerts
95+
.filter(rtdAlert => rtdAlert.EditedBy !== 'TRAMS')
96+
.map(rtdAlert => {
97+
// let activeIndex = action.projects.findIndex(p => p.id == config.activeProjectId)
98+
const {activeProject: project} = action
9799

98-
const alert = {
99-
id: rtdAlert.Id,
100-
title: rtdAlert.HeaderText,
101-
description: rtdAlert.DescriptionText.replace(/(\r\n)/g, '\n'), // RTD server sends back two-char new lines, which can mess up character limit counts
102-
cause: rtdAlert.Cause,
103-
effect: rtdAlert.Effect,
104-
editedBy: rtdAlert.EditedBy,
105-
editedDate: rtdAlert.EditedDate,
106-
url: rtdAlert.Url,
107-
start: rtdAlert.StartDateTime * 1000,
108-
end: rtdAlert.EndDateTime * 1000,
109-
published: rtdAlert.Published === 'Yes',
110-
affectedEntities: rtdAlert.ServiceAlertEntities.map((ent) => {
111-
const entity = {
112-
id: ent.Id
113-
}
114-
115-
if (ent.AgencyId !== null) {
116-
const feed = project.feedSources.find(f => getFeedId(f) === ent.AgencyId)
117-
entity.agency = feed
118-
entity.type = 'AGENCY'
119-
}
120-
121-
// stop goes ahead of route type and route because it's an optional field in the below
122-
if (ent.StopId !== null) {
123-
entity.stop_id = ent.StopId
124-
entity.type = 'STOP'
125-
}
126-
if (ent.RouteId !== null) {
127-
entity.route_id = ent.RouteId
128-
entity.type = 'ROUTE'
129-
}
130-
131-
if (ent.RouteType !== null) {
132-
const mode = modes.find(m => m.gtfsType === ent.RouteType)
133-
134-
// catch any integers outside of 0 -7 range
135-
entity.mode = typeof mode !== 'undefined' ? mode : modes.find(m => m.gtfsType === 0)
136-
entity.type = 'MODE'
137-
}
138-
return entity
139-
})
140-
}
141-
return alert
142-
})
100+
const alert = {
101+
id: rtdAlert.Id,
102+
title: rtdAlert.HeaderText,
103+
description: rtdAlert.DescriptionText.replace(/(\r\n)/g, '\n'), // RTD server sends back two-char new lines, which can mess up character limit counts
104+
cause: rtdAlert.Cause,
105+
effect: rtdAlert.Effect,
106+
editedBy: rtdAlert.EditedBy,
107+
editedDate: rtdAlert.EditedDate,
108+
url: rtdAlert.Url,
109+
start: rtdAlert.StartDateTime * 1000,
110+
end: rtdAlert.EndDateTime * 1000,
111+
published: rtdAlert.Published === 'Yes',
112+
affectedEntities: rtdAlert.ServiceAlertEntities.map(ent => {
113+
const entity = {
114+
id: ent.Id
115+
}
116+
if (ent.AgencyId !== null) {
117+
const feed = project.feedSources.find(f => getFeedId(f) === ent.AgencyId)
118+
entity.agency = feed
119+
entity.type = 'AGENCY'
120+
}
121+
// stop goes ahead of route type and route because it's an optional field in the below
122+
if (ent.StopId !== null) {
123+
entity.stop_id = ent.StopId
124+
entity.type = 'STOP'
125+
}
126+
if (ent.RouteId !== null) {
127+
entity.route_id = ent.RouteId
128+
entity.type = 'ROUTE'
129+
}
130+
if (ent.RouteType !== null) {
131+
const mode = modes.find(m => m.gtfsType === ent.RouteType)
132+
// catch any integers outside of 0 -7 range
133+
entity.mode = typeof mode !== 'undefined'
134+
? mode
135+
: modes.find(m => m.gtfsType === 0)
136+
entity.type = 'MODE'
137+
}
138+
return entity
139+
})
140+
}
141+
return alert
142+
})
143143
: []
144144
const filterCounts = {}
145145
FILTERS.map(f => {

0 commit comments

Comments
 (0)