This commit is contained in:
Kfir Dayan 2023-03-23 21:39:40 +02:00
parent 8770451ebc
commit 8c764da185
2 changed files with 0 additions and 52 deletions

View file

@ -10,15 +10,6 @@ import moment from 'moment'; // require
export default class GameSource {
constructor() { }
async getGamesFromSerapi() {
console.log("GET GAMES")
const sourceUrl = `https://serpapi.com/search.json?q=maccabi+haifa+next+games&api_key=${process.env.SERPAPI_KEY}&location=austin,+texas,+united+states`;
const result = await axios.get(sourceUrl)
const games = this.orderGames(result)
return games;
}
async getGamesFromHaifa() {
const sourceUrl = `https://mhaifafc.com/games?lang=en`;
const result = await axios.get(sourceUrl);
@ -63,46 +54,6 @@ export default class GameSource {
return games;
}
orderGames(result: any) {
const rootGames = result.data.sports_results;
const upcomingEvents: GoogleCalendarEvent[] = [];
upcomingEvents.push({
summary: rootGames.title,
location: rootGames.game_spotlight.stadium,
description: "Haifa vs. " + rootGames.game_spotlight.teams[this.getOpponentIndexByStadium(rootGames.game_spotlight.stadium)].name,
start: {
dateTime: `2023-03-22T09:00:00`,
timeZone: 'Asia/Jerusalem'
},
end: {
dateTime: `2023-03-22T11:00:00`,
timeZone: 'Asia/Jerusalem'
}
});
// console.log(rootGames.game_spotlight)
// console.log("DONE WITH UPDATING NEW EVENTS")
rootGames.games.forEach((game: any) => {
upcomingEvents.push({
summary: 'Maccabi Haifa F.C.',
location: game.stadium,
description: "Haifa vs. " + game.teams[this.getOpponentIndexByStadium(game.stadium)].name,
start: {
dateTime: `${game.date} ${game.time}`,
timeZone: 'Asia/Jerusalem'
},
end: {
dateTime: `${game.date} ${game.time}`,
timeZone: 'Asia/Jerusalem'
}
});
});
// console.log("UPCOMING EVENTS", upcomingEvents)
return upcomingEvents;
}
getOpponentIndexByStadium(stadium: string) {
if (stadium === "Sammy Ofer Stadium") {
return 1;

View file

@ -42,9 +42,6 @@ export default class GoogleCalendar {
}
async updateNewEvent(upcomingEvents: GoogleCalendarEvent[]) {
setTimeout(async () => {
upcomingEvents.forEach((event: GoogleCalendarEvent) => {
console.log("UPDATE NEW EVENT", upcomingEvents)