Compare commits

..

No commits in common. "90bb926341d897ebe08fa5e0c129b9d0c610a68d" and "d512ca8197f7ab29683ef0081c3ad7c6919dbe0d" have entirely different histories.

2 changed files with 26 additions and 13 deletions

View file

@ -12,33 +12,31 @@ export default class Ics {
output.push(this.generateIcsOutputFromGame(game));
});
console.log(output)
const { error, value } = ics.createEvents(output);
if (error) {
console.log(error);
return '';
}
console.log(value);
return value;
}
generateIcsOutputFromGame = (game: GoogleCalendarEvent) => {
const { summary, location, description, start, end } = game;
const icsEvent: ics.EventAttributes = {
title: description,
title: summary,
description,
location,
start: [start.dateTime[0], start.dateTime[1], start.dateTime[2], start.dateTime[3], start.dateTime[4]],
end: [end.dateTime[0], end.dateTime[1], end.dateTime[2], end.dateTime[3], end.dateTime[4]],
url: 'https://mhaifafc.com/',
status: 'CONFIRMED',
busyStatus: "BUSY",
productId: '-//kfir.dayanhub.com',
busyStatus: 'BUSY',
productId: 'https://mhaifafc.com/',
recurrenceRule: '',
attendees: [],
alarms: [],
categories: [],
organizer: { name: 'Maccabi Haifa F.C.', email: '' },
organizer: { name: 'Maccabi Haifa F.C.', email: '' }
};
return icsEvent;
}

View file

@ -1,3 +1,4 @@
// import GoogleCalendar from './GoogleCalendar';
import GameSource from './GameSource';
import fs from 'fs';
import Ics from './Ics';
@ -7,15 +8,29 @@ import env from 'dotenv';
env.config();
class App {
// googleCalendar: GoogleCalendar;
gameSource: GameSource;
ics: Ics;
googleToken: string;
constructor() {
// this.googleCalendar = new GoogleCalendar();
this.gameSource = new GameSource();
this.ics = new Ics();
}
// async init() {
// console.log("INIT APP")
// await this.googleCalendar.init();
// }
// async getNewGamesAndUpdateCalendar() {
// console.log("GET NEW GAMES AND UPDATE CALENDAR")
// const games = await this.gameSource.getGamesFromHaifa();
// this.googleCalendar.updateNewEvent(games);
// }
async startCronJob() {
console.log("START CRON JOB")
const CronJob = require('cron').CronJob;
@ -27,16 +42,16 @@ class App {
console.log("Getting games from Haifa")
const games = await app.gameSource.getGamesFromHaifa();
console.log("Generating ICS file")
const icsEvents = app.ics.generateIcsOutputFromGames([games[0]]);
const icsEvents = app.ics.generateIcsOutputFromGames(games);
console.log("Writing ICS file to " + outputFileLocation)
fs.writeFileSync(outputFileLocation, icsEvents);
console.log("Done Ics file")
// console.log("converting ics file to ical file")
// const outputIcalFileLocation = 'public/maccabi-haifa-fc.ical';
// const icalEvents = app.ics.convertIcsToIcal(icsEvents);
// console.log("Writing Ical file to " + outputIcalFileLocation)
// fs.writeFileSync(outputIcalFileLocation, icalEvents);
console.log("converting ics file to ical file")
const outputIcalFileLocation = 'public/maccabi-haifa-fc.ical';
const icalEvents = app.ics.convertIcsToIcal(icsEvents);
console.log("Writing Ical file to " + outputIcalFileLocation)
fs.writeFileSync(outputIcalFileLocation, icalEvents);
},
null,