Small improvement

This commit is contained in:
2025-04-19 17:55:39 +02:00
parent c6f070bdab
commit 9c060863f6

View File

@@ -1,18 +1,18 @@
package de.jeyp91.tippliga;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Objects;
import org.json.simple.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.jeyp91.apifootball.APIFootballMatch;
import de.jeyp91.apifootball.APIFootballMatchesProvider;
import de.jeyp91.teamidmatcher.TeamIDMatcher;
import de.jeyp91.tippligaforum.TippligaSQLConnector;
import de.jeyp91.tippligaforum.TippligaWebsiteConnector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Objects;
public class TLWMatchesResultsUpdater extends TLWMatchesManagerBase {
private static final Logger logger = LoggerFactory.getLogger(TLWMatchesResultsUpdater.class);
@@ -37,7 +37,6 @@ public class TLWMatchesResultsUpdater extends TLWMatchesManagerBase {
TippligaSQLConnector tippligaSQLConnector = TippligaSQLConnector.getInstance();
for (Object singleMatchdayConfig : this.matchdayConfig) {
int tlwMatchday = ((Long) ((JSONObject) singleMatchdayConfig).get("TLWMatchday")).intValue();
JSONArray matchesConfig = (JSONArray) ((JSONObject) singleMatchdayConfig).get("matchesConfig");
ArrayList<APIFootballMatch> apiFootballMatches = apiFootballMatchesProvider.getAPIFootballMatchesFromConfig((JSONObject) singleMatchdayConfig);
@@ -51,13 +50,13 @@ public class TLWMatchesResultsUpdater extends TLWMatchesManagerBase {
logger.error("Not matching config!");
}
if(apiFootballMatches.size() > 0) {
if(!apiFootballMatches.isEmpty()) {
updateResults(tlwMatchesUpdatedMatchday, apiFootballMatches);
}
updateBeautifulInfo(tlwMatchesOriginalMatchday, tlwMatchesUpdatedMatchday);
tlwMatchesUpdatedMatchday.removeIf(tlwMatch -> tlwMatch.getUpdateStatus() != TLWMatch.COMPARISON.DIFFERENT_RESULT);
if(tlwMatchesUpdatedMatchday.size() > 0) this.tlwMatchesUpdated.add(tlwMatchesUpdatedMatchday);
if(!tlwMatchesUpdatedMatchday.isEmpty()) this.tlwMatchesUpdated.add(tlwMatchesUpdatedMatchday);
}
}
@@ -131,6 +130,9 @@ public class TLWMatchesResultsUpdater extends TLWMatchesManagerBase {
private void updateBeautifulInfo(ArrayList<TLWMatch> matchesOriginal, ArrayList<TLWMatch> matchesUpdated) {
for (int i = 0; i < matchesOriginal.size(); i++) {
if(matchesUpdated.get(i).getUpdateStatus() != TLWMatch.COMPARISON.DIFFERENT_RESULT) {
continue;
}
updateBeautifulInfo(matchesOriginal.get(i), matchesUpdated.get(i));
}
}