Add support for API Football config without result and placeholder as fallback
This commit is contained in:
@@ -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<TLWMatch> matchesOfMatchday = getMatchesForMatchday(matches, matchdayNumber);
|
||||
if(matchesOfMatchday.size() == 0) {
|
||||
deliveryDate1 = matchesConfigPlaceholder.get("placeholderDatetime").toString();
|
||||
}
|
||||
else {
|
||||
ArrayList<TLWMatch> matchesOfMatchday = getMatchesForMatchday(matches, matchdayNumber);
|
||||
|
||||
LocalDateTime firstMatchDate = TLWMatchesManagerBase.getFirstMatchtimeTLW(matchesOfMatchday);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
deliveryDate1 = firstMatchDate.format(formatter);
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user