Updates for season 2022

This commit is contained in:
Julian Arndt
2021-07-19 15:05:48 +02:00
parent 6c9b86db09
commit 475ad08c81
16 changed files with 251 additions and 84 deletions
@@ -22,7 +22,7 @@ public class TLWMatchdaysCreator {
this.season = season;
this.league = league;
TLWMatchesCreatorFootball matchesCreator = new TLWMatchesCreatorFootball(2021, 1, configPath);
TLWMatchesCreatorFootball matchesCreator = new TLWMatchesCreatorFootball(season, 1, configPath);
this.matches = matchesCreator.getMatches();
TippligaConfigProvider prov = new TippligaConfigProvider(season);
@@ -32,6 +32,7 @@ public class TLWMatchesCreatorFootball extends TLWMatchesCreatorBase {
this.config = prov.getTippligaConfig(configFileName);
this.numberOfMatchdays = ((Long) this.config.get("numberOfMatchdays")).intValue();
this.matchesPerMatchday = ((Long) this.config.get("matchesPerMatchday")).intValue();
this.matchdayConfig = (JSONArray) this.config.get("matchdayConfig");
this.ko = ((Long) this.config.get("ko")).intValue();
String deliveryDateMode = this.config.containsKey("deliveryDateMode") ? this.config.get("deliveryDateMode").toString() : "";
@@ -46,11 +47,6 @@ public class TLWMatchesCreatorFootball extends TLWMatchesCreatorBase {
JSONArray matchesConfig = (JSONArray)((JSONObject) this.matchdayConfig.get(i)).get("matchesConfig");
ArrayList<APIFootballMatch> apiFootballMatchesForMatchday = getAPIFootballMatchesForMatchday(matchesConfig);
int tempNumberOfMatchesBackup = this.matchesPerMatchday;
if(((JSONObject) this.matchdayConfig.get(i)).containsKey("numberOfMatches")) {
this.matchesPerMatchday = ((Long) ((JSONObject) this.matchdayConfig.get(i)).get("numberOfMatches")).intValue();
}
int matchdayMatchCounter = 0;
// Use first matchtime because API Football always returns matches sorted by date
@@ -74,7 +70,15 @@ public class TLWMatchesCreatorFootball extends TLWMatchesCreatorBase {
}
// Add empty missing matches
for(int j = matchdayMatchCounter; j < this.matchesPerMatchday; j++) {
int matchesPerMatchdayTemp = 0;
if(this.matchesPerMatchday != 0) {
matchesPerMatchdayTemp = this.matchesPerMatchday;
} else {
if(((JSONObject) this.matchdayConfig.get(i)).containsKey("numberOfMatches")) {
matchesPerMatchdayTemp = ((Long) ((JSONObject) this.matchdayConfig.get(i)).get("numberOfMatches")).intValue();
}
}
for(int j = matchdayMatchCounter; j < matchesPerMatchdayTemp; j++) {
String matchDatetime = "";
if(apiFootballMatchesForMatchday.size() > 0) {
matchDatetime = this.TLWMatches.get(this.TLWMatches.size() - 1).getMatchDateTime();
@@ -86,10 +90,6 @@ public class TLWMatchesCreatorFootball extends TLWMatchesCreatorBase {
this.nextMatchNo++;
this.TLWMatches.add(new TLWMatch(this.season, this.league, TLWMatchday, matchNo, matchDatetime, 0, this.ko));
}
if(((JSONObject) this.matchdayConfig.get(i)).containsKey("numberOfMatches")) {
this.matchesPerMatchday = tempNumberOfMatchesBackup;
}
}
}
@@ -65,7 +65,7 @@ public class TLWTeamsCreator {
String getGroup(Integer teamId) {
for(TLWMatch match: matches) {
if(teamId.equals(match.getTeamIdHome()) || teamId.equals(match.getTeamIdGuest())) {
return match.getGroupId();
return match.getGroupId() != null ? match.getGroupId() : "";
}
}
return "";