Skip to content

Commit

Permalink
Standardizes entity naming in alert parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
jusimen committed Feb 12, 2025
1 parent b180f0a commit 3cfd741
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions apps/sync-alerts/src/services/parseAlertV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import type { Alert } from '@carrismetropolitana/api-types/gtfs-core';

export default function parseAlertV2(item): Alert {
//

const parsedInformedEntity = item.alert.informedEntity.map((entity) => {
const parsedInformedEntity = item.alert.informed_entity.map((entity) => {
if (entity.routeId) {
return {
lineId: entity.routeId.substring(0, 4),
line_id: entity.route_id.substring(0, 4),
...entity,
};
}
Expand All @@ -20,7 +19,7 @@ export default function parseAlertV2(item): Alert {
return {
...item.alert,
alert_id: item.id,
informedEntity: parsedInformedEntity,
informed_entity: parsedInformedEntity,
};

//
Expand Down
2 changes: 1 addition & 1 deletion apps/sync-alerts/src/tasks/sync-alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const syncAlerts = async () => {
for (const alertItem of allAlertsParsedV2) {
if (!allSentNotificationsSet.has(alertItem['_id'])) {
try {
for (const entity of alertItem['informedEntity']) {
for (const entity of alertItem['informed_entity']) {
// Setup notification message
const notificationMessage: TopicMessage = {
apns: {
Expand Down

0 comments on commit 3cfd741

Please sign in to comment.