cleaning
This commit is contained in:
parent
8770451ebc
commit
8c764da185
2 changed files with 0 additions and 52 deletions
|
@ -10,15 +10,6 @@ import moment from 'moment'; // require
|
||||||
export default class GameSource {
|
export default class GameSource {
|
||||||
constructor() { }
|
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() {
|
async getGamesFromHaifa() {
|
||||||
const sourceUrl = `https://mhaifafc.com/games?lang=en`;
|
const sourceUrl = `https://mhaifafc.com/games?lang=en`;
|
||||||
const result = await axios.get(sourceUrl);
|
const result = await axios.get(sourceUrl);
|
||||||
|
@ -63,46 +54,6 @@ export default class GameSource {
|
||||||
return games;
|
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) {
|
getOpponentIndexByStadium(stadium: string) {
|
||||||
if (stadium === "Sammy Ofer Stadium") {
|
if (stadium === "Sammy Ofer Stadium") {
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -42,9 +42,6 @@ export default class GoogleCalendar {
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateNewEvent(upcomingEvents: GoogleCalendarEvent[]) {
|
async updateNewEvent(upcomingEvents: GoogleCalendarEvent[]) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
upcomingEvents.forEach((event: GoogleCalendarEvent) => {
|
upcomingEvents.forEach((event: GoogleCalendarEvent) => {
|
||||||
console.log("UPDATE NEW EVENT", upcomingEvents)
|
console.log("UPDATE NEW EVENT", upcomingEvents)
|
||||||
|
|
Loading…
Reference in a new issue