Add show table update, add matches list creator

This commit is contained in:
2020-10-31 20:26:47 +01:00
parent 57baee27bd
commit 3a5df3cae6
17 changed files with 195 additions and 32 deletions
@@ -1,6 +1,5 @@
package de.jeyp91.tippliga;
import com.google.api.client.util.DateTime;
import de.jeyp91.App;
import de.jeyp91.TeamIDMatcher;
import de.jeyp91.apifootball.APIFootballMatch;
@@ -10,14 +9,11 @@ import org.apache.logging.log4j.Logger;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import javax.sound.midi.SysexMessage;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
private static Logger logger = LogManager.getLogger(App.class);
private static final Logger logger = LogManager.getLogger(App.class);
ArrayList<TLWMatch> tlwMatchesOriginal;
ArrayList<TLWMatch> tlwMatchesUpdated;
@@ -47,7 +43,9 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
ArrayList<TLWMatch> tlwMatchesOriginalMatchday = tippligaSQLConnector.getMatches(String.valueOf(this.season), String.valueOf(this.league), String.valueOf(tlwMatchday));
ArrayList<TLWMatch> tlwMatchesUpdatedMatchday = new ArrayList<>();
for (TLWMatch match : tlwMatchesOriginalMatchday) tlwMatchesUpdatedMatchday.add(new TLWMatch(match));
for (TLWMatch match : tlwMatchesOriginalMatchday) {
tlwMatchesUpdatedMatchday.add(new TLWMatch(match));
}
if (apiFootballMatches.size() > tlwMatchesUpdatedMatchday.size()) {
logger.error("Not matching config!");
@@ -55,6 +53,7 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
addMissingMatches(tlwMatchesUpdatedMatchday, apiFootballMatches);
updateMatchDateTimes(tlwMatchesUpdatedMatchday, apiFootballMatches);
updateShowTable(tlwMatchesUpdatedMatchday, apiFootballMatches);
updateStatus(tlwMatchesUpdatedMatchday);
this.tlwMatchesOriginal.addAll(tlwMatchesOriginalMatchday);
@@ -87,7 +86,7 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
"Spielnummer " + matchOriginal.getMatchNo() + ", " +
"Spiel '" + TeamIDMatcher.getTeamNameFromTippligaId(matchOriginal.getTeamIdHome()) + "' - '" + TeamIDMatcher.getTeamNameFromTippligaId(matchOriginal.getTeamIdGuest()) + "', ";
if(matchOriginal.getTeamIdHome() != matchUpdated.getTeamIdHome()) {
if(!matchOriginal.getTeamIdHome().equals(matchUpdated.getTeamIdHome())) {
updateString += updateStart +
"team_id_home = " + matchUpdated.getTeamIdHome() + " " +
condition;
@@ -95,7 +94,7 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
"Heimteam zu '" + matchUpdated.getTeamNameHome() + "'.\n";
}
if(matchOriginal.getTeamIdGuest() != matchUpdated.getTeamIdGuest()) {
if(!matchOriginal.getTeamIdGuest().equals(matchUpdated.getTeamIdGuest())) {
updateString += updateStart +
"team_id_guest = " + matchUpdated.getTeamIdGuest() + " " +
condition;
@@ -119,6 +118,14 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
"Status zu '" + matchUpdated.getStatus() + "'.\n";
}
if (!matchOriginal.getShowTable().equals(matchUpdated.getShowTable())) {
updateString += updateStart +
"show_table = '" + matchUpdated.getShowTable() + "' " +
condition;
this.beautifulInfo += beautifulInfoStart +
"Spiel in Tabelle einberechnen zu '" + (matchUpdated.getShowTable() == 1 ? "falsch" : "wahr") + "'.\n";
}
return updateString;
}
@@ -174,6 +181,16 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
}
}
private void updateShowTable(
ArrayList<TLWMatch> tlwMatches,
ArrayList<APIFootballMatch> apiFootballMatches)
{
for(APIFootballMatch apiFootballMatch : apiFootballMatches) {
TLWMatch tlwMatch = getMatchingMatch(apiFootballMatch, tlwMatches);
tlwMatch.setShowTable(apiFootballMatch.getShowTable());
}
}
private TLWMatch getMatchingMatch(APIFootballMatch apiFootballMatch, ArrayList<TLWMatch> tlwMatches) {
int foundMatches = 0;
TLWMatch matchingMatch = null;