Use league name from database for calendar
This commit is contained in:
@@ -4,10 +4,9 @@ import com.google.api.client.util.DateTime;
|
||||
import com.google.api.services.calendar.Calendar;
|
||||
import com.google.api.services.calendar.model.Event;
|
||||
import com.google.api.services.calendar.model.EventDateTime;
|
||||
import com.google.api.services.calendar.model.EventReminder;
|
||||
import com.google.api.services.calendar.model.Events;
|
||||
import de.jeyp91.tippliga.TLWLeague;
|
||||
import de.jeyp91.tippliga.TLWMatchday;
|
||||
import de.jeyp91.tippligaforum.TippligaSQLConnector;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -16,7 +15,7 @@ import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static de.jeyp91.googlecalendar.GoogleCalendarConnector.getSerivce;
|
||||
@@ -26,6 +25,8 @@ public class TippligaGoogleEventManager {
|
||||
private static List<Event> allEvents = null;
|
||||
private static final Logger logger = LogManager.getLogger(TippligaGoogleEventManager.class);
|
||||
|
||||
private static final HashMap<String, String> allLeagueNames = new HashMap<>();
|
||||
|
||||
public static List<Event> getAllEvents(Integer season) {
|
||||
if(allEvents == null) {
|
||||
allEvents = getAllEventsStartingFromDateTime(new DateTime(season-1 + "-07-01T00:00:00Z"));
|
||||
@@ -144,7 +145,7 @@ public class TippligaGoogleEventManager {
|
||||
|
||||
private static Event getEvent(TLWMatchday matchday, String deliveryDateString, Integer deliverDateNumber) {
|
||||
String matchdayName = matchday.getMatchdayName().equals("") ? matchday.getMatchday().toString() + ". Spieltag" : matchday.getMatchdayName();
|
||||
String summary = TLWLeague.getLeagueNameCalendar(matchday.getLeague()) + " " + matchdayName + " tippen!";
|
||||
String summary = getLeagueNameCalendar(matchday.getSeason(), matchday.getLeague()) + " " + matchdayName + " tippen!";
|
||||
if(deliverDateNumber > 1) summary += " " + deliverDateNumber + ". Chance \uD83D\uDE43";
|
||||
String description = getDescription(matchday.getSeason(), matchday.getLeague(), matchday.getMatchday(), deliverDateNumber);
|
||||
String location = "https://tippliga-wuerzburg.de/app.php/football/bet";
|
||||
@@ -195,4 +196,13 @@ public class TippligaGoogleEventManager {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static String getLeagueNameCalendar(Integer season, Integer league) {
|
||||
String seasonLeagueId = season.toString() + league.toString();
|
||||
|
||||
if(!allLeagueNames.containsKey(seasonLeagueId)) {
|
||||
allLeagueNames.put(seasonLeagueId, TippligaSQLConnector.getInstance().getLeague(season.toString(), league.toString()).getLeagueNameCalendar());
|
||||
}
|
||||
return allLeagueNames.get(seasonLeagueId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user