diff --git a/dist/GameSource.js b/dist/GameSource.js index 1026499..18fc61e 100644 --- a/dist/GameSource.js +++ b/dist/GameSource.js @@ -31,7 +31,7 @@ class GameSource { const end = (0, moment_1.default)(gameDate + gameTime, "DD/MM/YYYYHH:mm").add(2, "hours").toISOString(); games.push({ summary: 'Maccabi Haifa F.C.', - location: "Ofir's stadium", + location: headerSplit[4].trim(), description: `${teamsPlaying[0]} vs. ${teamsPlaying[1]}`, start: { dateTime: start, diff --git a/dist/index.js b/dist/index.js index a00248a..7be145c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true }); const GameSource_1 = __importDefault(require("./GameSource")); const GoogleCalendar_1 = __importDefault(require("./GoogleCalendar")); const dotenv_1 = __importDefault(require("dotenv")); -const node_cron_1 = __importDefault(require("node-cron")); dotenv_1.default.config(); class App { constructor() { @@ -17,24 +16,22 @@ class App { console.log("START CRON JOB"); await this.googleCalendar.init(); // Schedule the job to run daily at a specific time (e.g., 1:00 AM) - node_cron_1.default.schedule("* * * * *", async () => { - try { - const games = await app.gameSource.getGamesFromHaifa(); - for (const game of games) { - const isDuplicateEvent = await this.googleCalendar.isDuplicateEvent(game.start.dateTime, game.end.dateTime, game.summary); - if (!isDuplicateEvent) { - console.log("Event does not exist"); - await this.googleCalendar.updateNewEvent([game]); - } - else { - console.log("Event already exists"); - } + try { + const games = await app.gameSource.getGamesFromHaifa(); + for (const game of games) { + const isDuplicateEvent = await this.googleCalendar.isDuplicateEvent(game.start.dateTime, game.end.dateTime, game.summary); + if (!isDuplicateEvent) { + console.log("Event does not exist"); + await this.googleCalendar.updateNewEvent([game]); + } + else { + console.log("Event already exists"); } } - catch (error) { - console.error("Error in cron job:", error.message); - } - }); + } + catch (error) { + console.error("Error in cron job:", error.message); + } } } const app = new App(); diff --git a/src/GameSource.ts b/src/GameSource.ts index 999fd91..ecfddc3 100644 --- a/src/GameSource.ts +++ b/src/GameSource.ts @@ -29,13 +29,15 @@ export default class GameSource { const gameDate = headerSplit[2].trim(); const gameTime = headerSplit[3].trim(); - + const start = moment(gameDate + gameTime, "DD/MM/YYYYHH:mm").toISOString(); const end = moment(gameDate + gameTime, "DD/MM/YYYYHH:mm").add(2, "hours").toISOString(); + + games.push({ summary: 'Maccabi Haifa F.C.', - location: "Ofir's stadium", + location: headerSplit[4].trim(), description: `${teamsPlaying[0]} vs. ${teamsPlaying[1]}`, start: { dateTime: start, diff --git a/src/index.ts b/src/index.ts index 53a61d4..3424953 100644 --- a/src/index.ts +++ b/src/index.ts @@ -21,7 +21,6 @@ class App { await this.googleCalendar.init(); // Schedule the job to run daily at a specific time (e.g., 1:00 AM) - cron.schedule("* * * * *", async () => { try { const games = await app.gameSource.getGamesFromHaifa(); @@ -42,7 +41,6 @@ class App { } catch (error) { console.error("Error in cron job:", error.message); } - }); } }