adding logs outputs of handeling events

This commit is contained in:
Kfir Dayan 2024-01-23 11:53:52 +02:00
parent 522d30d7dd
commit 54483b96b6
2 changed files with 4 additions and 9 deletions

6
dist/index.js vendored
View file

@ -16,11 +16,11 @@ class App {
console.log("START CRON JOB"); console.log("START CRON JOB");
const newGamesAdded = []; const newGamesAdded = [];
await this.googleCalendar.init(); await this.googleCalendar.init();
// Schedule the job to run daily at a specific time (e.g., 1:00 AM)
try { try {
const games = await app.gameSource.getGamesFromHaifa(); const games = await app.gameSource.getGamesFromHaifa();
for (const game of games) { for (const game of games) {
const isDuplicateEvent = await this.googleCalendar.isDuplicateEvent(game.start.dateTime, game.end.dateTime, game.summary); const isDuplicateEvent = await this.googleCalendar.isDuplicateEvent(game.start.dateTime, game.end.dateTime, game.summary);
console.log(game);
if (!isDuplicateEvent) { if (!isDuplicateEvent) {
newGamesAdded.push(game); newGamesAdded.push(game);
console.log("Event does not exist"); console.log("Event does not exist");
@ -28,15 +28,13 @@ class App {
} }
else { else {
console.log("Event already exists"); console.log("Event already exists");
console.log("Event:");
console.log("Happening at:");
} }
} }
if (newGamesAdded.length > 0) { if (newGamesAdded.length > 0) {
console.log("New games added:", newGamesAdded); console.log("New games added:", newGamesAdded);
} }
else { else {
console.log("No new games added"); console.log("No new games was Added!");
} }
} }
catch (error) { catch (error) {

View file

@ -18,7 +18,6 @@ class App {
console.log("START CRON JOB"); console.log("START CRON JOB");
const newGamesAdded = []; const newGamesAdded = [];
await this.googleCalendar.init(); await this.googleCalendar.init();
// Schedule the job to run daily at a specific time (e.g., 1:00 AM)
try { try {
const games = await app.gameSource.getGamesFromHaifa(); const games = await app.gameSource.getGamesFromHaifa();
@ -28,22 +27,20 @@ class App {
game.end.dateTime, game.end.dateTime,
game.summary game.summary
); );
console.log(game)
if (!isDuplicateEvent) { if (!isDuplicateEvent) {
newGamesAdded.push(game); newGamesAdded.push(game);
console.log("Event does not exist"); console.log("Event does not exist");
await this.googleCalendar.updateNewEvent([game]); await this.googleCalendar.updateNewEvent([game]);
} else { } else {
console.log("Event already exists"); console.log("Event already exists");
console.log("Event:");
console.log("Happening at:");
} }
} }
if(newGamesAdded.length > 0) { if(newGamesAdded.length > 0) {
console.log("New games added:", newGamesAdded); console.log("New games added:", newGamesAdded);
} else { } else {
console.log("No new games added"); console.log("No new games was Added!");
} }
} catch (error) { } catch (error) {
console.error("Error in cron job:", error.message); console.error("Error in cron job:", error.message);