Add several improvements for EM

This commit is contained in:
2024-06-08 00:12:59 +02:00
parent 10b5cc2f9c
commit 1889be5b14
10 changed files with 215 additions and 57 deletions

View File

@@ -12,9 +12,15 @@ public class APIFootballMatchesProvider {
this.conn = APIFootballConnector.getAPIFootballConnectorInstance(season - 1);
}
public ArrayList<APIFootballMatch> getAPIFootballMatchesFromConfig(JSONArray config) {
public ArrayList<APIFootballMatch> getAPIFootballMatchesFromConfig(JSONObject matchdayConfig) {
boolean ko = false;
try {
ko = (boolean) matchdayConfig.get("ko");
} catch (Exception e) {
// Nothing to do here
}
ArrayList<APIFootballMatch> apiFootballMatches = new ArrayList<>();
for (Object singleConfigObject : config) {
for (Object singleConfigObject : (JSONArray) matchdayConfig.get("matchesConfig")) {
JSONObject singleConfig = (JSONObject) singleConfigObject;
String type = (String) singleConfig.get("type");
boolean showTable = false;
@@ -29,7 +35,11 @@ public class APIFootballMatchesProvider {
e.printStackTrace();
}
boolean finalShowTable = showTable;
matches.forEach(apiFootballMatch -> apiFootballMatch.setShowTable(finalShowTable));
boolean finalKo = ko;
matches.forEach(apiFootballMatch -> {
apiFootballMatch.setShowTable(finalShowTable);
apiFootballMatch.setKoMatch(finalKo);
});
apiFootballMatches.addAll(matches);
break;
case "SingleMatch":
@@ -38,6 +48,7 @@ public class APIFootballMatchesProvider {
APIFootballMatch match = conn.getMatchDataByLeagueAndMatchID(matchLeague, matchId);
showTable = (boolean) singleConfig.get("showTable");
match.setShowTable(showTable);
match.setKoMatch(ko);
apiFootballMatches.add(match);
break;
}