diff --git a/src/main/java/de/jeyp91/tippliga/TLWMatchesResultsUpdater.java b/src/main/java/de/jeyp91/tippliga/TLWMatchesResultsUpdater.java index 9b38910..8452549 100644 --- a/src/main/java/de/jeyp91/tippliga/TLWMatchesResultsUpdater.java +++ b/src/main/java/de/jeyp91/tippliga/TLWMatchesResultsUpdater.java @@ -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 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 matchesOriginal, ArrayList 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)); } }