diff --git a/src/main/java/de/jeyp91/tippliga/TLWMatchdaysCreator.java b/src/main/java/de/jeyp91/tippliga/TLWMatchdaysCreator.java index c0d226c..129b02e 100644 --- a/src/main/java/de/jeyp91/tippliga/TLWMatchdaysCreator.java +++ b/src/main/java/de/jeyp91/tippliga/TLWMatchdaysCreator.java @@ -59,13 +59,12 @@ public class TLWMatchdaysCreator { String deliveryDate2 = null; JSONArray matchesConfig = (JSONArray) matchdayConfigJson.get("matchesConfig"); - JSONObject matchesConfigOne = (JSONObject) matchesConfig.get(0); - if(matchesConfigOne.get("type").toString().equals("ToBeDefined")) { - deliveryDate1 = matchesConfigOne.get("placeholderDatetime").toString(); + JSONObject matchesConfigPlaceholder = (JSONObject) matchesConfig.get(matchesConfig.size() - 1); + ArrayList matchesOfMatchday = getMatchesForMatchday(matches, matchdayNumber); + if(matchesOfMatchday.size() == 0) { + deliveryDate1 = matchesConfigPlaceholder.get("placeholderDatetime").toString(); } else { - ArrayList matchesOfMatchday = getMatchesForMatchday(matches, matchdayNumber); - LocalDateTime firstMatchDate = TLWMatchesManagerBase.getFirstMatchtimeTLW(matchesOfMatchday); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); deliveryDate1 = firstMatchDate.format(formatter); diff --git a/src/main/java/de/jeyp91/tippliga/TLWMatchesCreatorFootball.java b/src/main/java/de/jeyp91/tippliga/TLWMatchesCreatorFootball.java index 4c2487f..e79c239 100644 --- a/src/main/java/de/jeyp91/tippliga/TLWMatchesCreatorFootball.java +++ b/src/main/java/de/jeyp91/tippliga/TLWMatchesCreatorFootball.java @@ -88,12 +88,12 @@ public class TLWMatchesCreatorFootball extends TLWMatchesCreatorBase { // Add empty missing matches for(int j = matchdayMatchCounter; j < this.matchesPerMatchday; j++) { String matchDatetime = ""; - if(((JSONObject) matchesConfig.get(0)).get("type").toString().equals("ToBeDefined")) { - matchDatetime = ((JSONObject) matchesConfig.get(0)).get("placeholderDatetime").toString(); - } - else if(apiFootballMatchesForMatchday.size() > 0) { + if(apiFootballMatchesForMatchday.size() > 0) { matchDatetime = this.TLWMatches.get(this.TLWMatches.size() - 1).getMatchDateTime(); } + else { + matchDatetime = ((JSONObject) matchesConfig.get(matchesConfig.size() - 1)).get("placeholderDatetime").toString(); + } int matchNo = this.nextMatchNo; this.nextMatchNo++; this.TLWMatches.add(new TLWMatch(this.season, this.league, TLWMatchday, matchNo, matchDatetime, 0, this.ko)); diff --git a/src/main/java/de/jeyp91/tippliga/TLWMatchesUpdaterFootball.java b/src/main/java/de/jeyp91/tippliga/TLWMatchesUpdaterFootball.java index 1fc96bd..7d66bc6 100644 --- a/src/main/java/de/jeyp91/tippliga/TLWMatchesUpdaterFootball.java +++ b/src/main/java/de/jeyp91/tippliga/TLWMatchesUpdaterFootball.java @@ -1,6 +1,7 @@ package de.jeyp91.tippliga; import de.jeyp91.App; +import de.jeyp91.StatusHolder; import de.jeyp91.TeamIDMatcher; import de.jeyp91.apifootball.APIFootballMatch; import de.jeyp91.apifootball.APIFootballMatchesProvider; @@ -170,6 +171,10 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase { { for(APIFootballMatch apiFootballMatch : apiFootballMatches) { TLWMatch tlwMatch = getMatchingMatch(apiFootballMatch, tlwMatches); + if(tlwMatch == null) { + StatusHolder.setError(); + logger.error("Did not find match to update"); + } tlwMatch.setMatchDateTime(apiFootballMatch.getMatchDateTime().replace("T", " ").substring(0, 19)); } } diff --git a/src/test/java/de/jeyp91/tippliga/TLWMatchesUpdaterFootballTest.java b/src/test/java/de/jeyp91/tippliga/TLWMatchesUpdaterFootballTest.java index 82fdeeb..4a8ac6e 100644 --- a/src/test/java/de/jeyp91/tippliga/TLWMatchesUpdaterFootballTest.java +++ b/src/test/java/de/jeyp91/tippliga/TLWMatchesUpdaterFootballTest.java @@ -21,4 +21,13 @@ public class TLWMatchesUpdaterFootballTest { System.out.println(sql); System.out.println(updater.getBeautifulInfo()); } + + @Test + public void getUpdateSqlTest48() { + TLWMatchesUpdaterFootball updater = new TLWMatchesUpdaterFootball(2021, 48, "WTL_Pokal.json"); + String sql = updater.getUpdateSQL(); + + System.out.println(sql); + System.out.println(updater.getBeautifulInfo()); + } } diff --git a/tokens/StoredCredential b/tokens/StoredCredential index 99ee11e..ab7d7b9 100644 Binary files a/tokens/StoredCredential and b/tokens/StoredCredential differ