Skip to content

Commit 0558c1c

Browse files
authored
get RTF data from source (#358)
1 parent 94c7807 commit 0558c1c

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ app.use('/api/v1/', ecosystemRoutes);
4747
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDoc));
4848

4949
// Setup recurring events (every 30 seconds)
50-
schedule.scheduleJob("*/30 * * * * *", () => {
50+
schedule.scheduleJob("*/30 * * * * *", async () => {
5151
AlertsUtils.fetchAlerts();
52-
RealtimeFeedUtilsV3.fetchRTF();
52+
await RealtimeFeedUtilsV3.fetchRTF();
5353
AllStopUtils.fetchAllStops();
5454
RealtimeFeedUtilsV3.fetchVehicles();
5555
NotificationUtils.sendNotifications();

src/utils/NotificationUtils.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import schedule from "node-schedule";
33
import { fileURLToPath } from "url";
44
import fs from "fs";
55
import path from "path";
6+
import RealtimeFeedUtilsV3 from "./RealtimeFeedUtilsV3.js";
67

78
const __filename = fileURLToPath(import.meta.url);
89
const __dirname = path.dirname(__filename);
910
const notifPath = path.join(__dirname, "..", "data", "notifRequests.json");
1011

1112
let notifRequests;
12-
let rtfData;
1313

1414
try {
1515
const data = fs.readFileSync(notifPath, "utf8");
@@ -58,6 +58,13 @@ function deleteDelayNotification(tripID, stopID, deviceToken) {
5858
}
5959

6060
function sendNotifications() {
61+
const rtfData = RealtimeFeedUtilsV3.getRTFData();
62+
63+
if (!rtfData) {
64+
// no real-time data available yet
65+
return;
66+
}
67+
6168
for (const id in rtfData) {
6269
if (id in notifRequests) {
6370
for (const stopID in notifRequests[id]) {

0 commit comments

Comments
 (0)