Small improvement
This commit is contained in:
@@ -1,18 +1,18 @@
|
|||||||
package de.jeyp91.tippliga;
|
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.APIFootballMatch;
|
||||||
import de.jeyp91.apifootball.APIFootballMatchesProvider;
|
import de.jeyp91.apifootball.APIFootballMatchesProvider;
|
||||||
import de.jeyp91.teamidmatcher.TeamIDMatcher;
|
import de.jeyp91.teamidmatcher.TeamIDMatcher;
|
||||||
import de.jeyp91.tippligaforum.TippligaSQLConnector;
|
import de.jeyp91.tippligaforum.TippligaSQLConnector;
|
||||||
import de.jeyp91.tippligaforum.TippligaWebsiteConnector;
|
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 {
|
public class TLWMatchesResultsUpdater extends TLWMatchesManagerBase {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(TLWMatchesResultsUpdater.class);
|
private static final Logger logger = LoggerFactory.getLogger(TLWMatchesResultsUpdater.class);
|
||||||
@@ -37,7 +37,6 @@ public class TLWMatchesResultsUpdater extends TLWMatchesManagerBase {
|
|||||||
TippligaSQLConnector tippligaSQLConnector = TippligaSQLConnector.getInstance();
|
TippligaSQLConnector tippligaSQLConnector = TippligaSQLConnector.getInstance();
|
||||||
for (Object singleMatchdayConfig : this.matchdayConfig) {
|
for (Object singleMatchdayConfig : this.matchdayConfig) {
|
||||||
int tlwMatchday = ((Long) ((JSONObject) singleMatchdayConfig).get("TLWMatchday")).intValue();
|
int tlwMatchday = ((Long) ((JSONObject) singleMatchdayConfig).get("TLWMatchday")).intValue();
|
||||||
JSONArray matchesConfig = (JSONArray) ((JSONObject) singleMatchdayConfig).get("matchesConfig");
|
|
||||||
|
|
||||||
ArrayList<APIFootballMatch> apiFootballMatches = apiFootballMatchesProvider.getAPIFootballMatchesFromConfig((JSONObject) singleMatchdayConfig);
|
ArrayList<APIFootballMatch> apiFootballMatches = apiFootballMatchesProvider.getAPIFootballMatchesFromConfig((JSONObject) singleMatchdayConfig);
|
||||||
|
|
||||||
@@ -51,13 +50,13 @@ public class TLWMatchesResultsUpdater extends TLWMatchesManagerBase {
|
|||||||
logger.error("Not matching config!");
|
logger.error("Not matching config!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(apiFootballMatches.size() > 0) {
|
if(!apiFootballMatches.isEmpty()) {
|
||||||
updateResults(tlwMatchesUpdatedMatchday, apiFootballMatches);
|
updateResults(tlwMatchesUpdatedMatchday, apiFootballMatches);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateBeautifulInfo(tlwMatchesOriginalMatchday, tlwMatchesUpdatedMatchday);
|
updateBeautifulInfo(tlwMatchesOriginalMatchday, tlwMatchesUpdatedMatchday);
|
||||||
tlwMatchesUpdatedMatchday.removeIf(tlwMatch -> tlwMatch.getUpdateStatus() != TLWMatch.COMPARISON.DIFFERENT_RESULT);
|
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) {
|
private void updateBeautifulInfo(ArrayList<TLWMatch> matchesOriginal, ArrayList<TLWMatch> matchesUpdated) {
|
||||||
for (int i = 0; i < matchesOriginal.size(); i++) {
|
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));
|
updateBeautifulInfo(matchesOriginal.get(i), matchesUpdated.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user