Compare commits

..

2 commits

Author SHA1 Message Date
f95ed86012 remove node_modules 2023-07-26 15:15:38 +03:00
95b2f4283b done manually 2023-07-26 15:14:58 +03:00
5 changed files with 22 additions and 23 deletions

4
.gitignore vendored
View file

@ -1,8 +1,9 @@
## Node modules ## ## Node modules ##
# node_modules node_modules
#javascript build files # #javascript build files #
public/**/* public/**/*
dist/**/*
# Tmp files # # Tmp files #
tmp tmp
@ -10,6 +11,7 @@ tmp
## ENV Vars ## ## ENV Vars ##
.env .env
config/client_google_auth.json
## Docker ## ## Docker ##
build_image.sh build_image.sh

2
dist/GameSource.js vendored
View file

@ -31,7 +31,7 @@ class GameSource {
const end = (0, moment_1.default)(gameDate + gameTime, "DD/MM/YYYYHH:mm").add(2, "hours").toISOString(); const end = (0, moment_1.default)(gameDate + gameTime, "DD/MM/YYYYHH:mm").add(2, "hours").toISOString();
games.push({ games.push({
summary: 'Maccabi Haifa F.C.', summary: 'Maccabi Haifa F.C.',
location: "Ofir's stadium", location: headerSplit[4].trim(),
description: `${teamsPlaying[0]} vs. ${teamsPlaying[1]}`, description: `${teamsPlaying[0]} vs. ${teamsPlaying[1]}`,
start: { start: {
dateTime: start, dateTime: start,

31
dist/index.js vendored
View file

@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
const GameSource_1 = __importDefault(require("./GameSource")); const GameSource_1 = __importDefault(require("./GameSource"));
const GoogleCalendar_1 = __importDefault(require("./GoogleCalendar")); const GoogleCalendar_1 = __importDefault(require("./GoogleCalendar"));
const dotenv_1 = __importDefault(require("dotenv")); const dotenv_1 = __importDefault(require("dotenv"));
const node_cron_1 = __importDefault(require("node-cron"));
dotenv_1.default.config(); dotenv_1.default.config();
class App { class App {
constructor() { constructor() {
@ -17,24 +16,22 @@ class App {
console.log("START CRON JOB"); console.log("START CRON JOB");
await this.googleCalendar.init(); await this.googleCalendar.init();
// Schedule the job to run daily at a specific time (e.g., 1:00 AM) // Schedule the job to run daily at a specific time (e.g., 1:00 AM)
node_cron_1.default.schedule("* * * * *", async () => { 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); if (!isDuplicateEvent) {
if (!isDuplicateEvent) { 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");
}
} }
} }
catch (error) { }
console.error("Error in cron job:", error.message); catch (error) {
} console.error("Error in cron job:", error.message);
}); }
} }
} }
const app = new App(); const app = new App();

View file

@ -33,9 +33,11 @@ export default class GameSource {
const start = moment(gameDate + gameTime, "DD/MM/YYYYHH:mm").toISOString(); const start = moment(gameDate + gameTime, "DD/MM/YYYYHH:mm").toISOString();
const end = moment(gameDate + gameTime, "DD/MM/YYYYHH:mm").add(2, "hours").toISOString(); const end = moment(gameDate + gameTime, "DD/MM/YYYYHH:mm").add(2, "hours").toISOString();
games.push({ games.push({
summary: 'Maccabi Haifa F.C.', summary: 'Maccabi Haifa F.C.',
location: "Ofir's stadium", location: headerSplit[4].trim(),
description: `${teamsPlaying[0]} vs. ${teamsPlaying[1]}`, description: `${teamsPlaying[0]} vs. ${teamsPlaying[1]}`,
start: { start: {
dateTime: start, dateTime: start,

View file

@ -21,7 +21,6 @@ class App {
await this.googleCalendar.init(); await this.googleCalendar.init();
// Schedule the job to run daily at a specific time (e.g., 1:00 AM) // Schedule the job to run daily at a specific time (e.g., 1:00 AM)
cron.schedule("* * * * *", async () => {
try { try {
const games = await app.gameSource.getGamesFromHaifa(); const games = await app.gameSource.getGamesFromHaifa();
@ -42,7 +41,6 @@ class App {
} catch (error) { } catch (error) {
console.error("Error in cron job:", error.message); console.error("Error in cron job:", error.message);
} }
});
} }
} }