Add several improvements for EM
This commit is contained in:
@@ -6,8 +6,8 @@ apply plugin: 'java'
|
|||||||
apply plugin: 'application'
|
apply plugin: 'application'
|
||||||
|
|
||||||
mainClassName = 'App'
|
mainClassName = 'App'
|
||||||
sourceCompatibility = 11
|
sourceCompatibility = 15
|
||||||
targetCompatibility = 11
|
targetCompatibility = 15
|
||||||
version = '1.0'
|
version = '1.0'
|
||||||
compileJava.options.encoding = 'UTF-8'
|
compileJava.options.encoding = 'UTF-8'
|
||||||
compileTestJava.options.encoding = 'UTF-8'
|
compileTestJava.options.encoding = 'UTF-8'
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ public abstract class BaseMatch {
|
|||||||
protected Integer matchday = null;
|
protected Integer matchday = null;
|
||||||
protected String matchDatetime = null;
|
protected String matchDatetime = null;
|
||||||
protected Integer status = null;
|
protected Integer status = null;
|
||||||
|
protected Integer koMatch = 0;
|
||||||
|
protected Integer showTable = 0;
|
||||||
protected COMPARISON updateStatus = COMPARISON.IDENTICAL;
|
protected COMPARISON updateStatus = COMPARISON.IDENTICAL;
|
||||||
|
|
||||||
public Integer getMatchday() {
|
public Integer getMatchday() {
|
||||||
@@ -86,6 +88,22 @@ public abstract class BaseMatch {
|
|||||||
return this.status;
|
return this.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getShowTable() {
|
||||||
|
return this.koMatch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowTable(boolean showTable) {
|
||||||
|
this.showTable = showTable ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getKoMatch() {
|
||||||
|
return this.koMatch == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKoMatch(Boolean koMatch) {
|
||||||
|
this.koMatch = koMatch ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
public void setUpdateStatus(COMPARISON newStatus) { this.updateStatus = newStatus; }
|
public void setUpdateStatus(COMPARISON newStatus) { this.updateStatus = newStatus; }
|
||||||
|
|
||||||
public COMPARISON getUpdateStatus() {
|
public COMPARISON getUpdateStatus() {
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ public class APIFootballMatch extends BaseMatch {
|
|||||||
private String teamNameHome;
|
private String teamNameHome;
|
||||||
private String teamNameGuest;
|
private String teamNameGuest;
|
||||||
private String round;
|
private String round;
|
||||||
private Boolean showTable = null;
|
|
||||||
|
|
||||||
public APIFootballMatch(JSONObject json, int season) throws Exception {
|
public APIFootballMatch(JSONObject json, int season) throws Exception {
|
||||||
this.matchId = Integer.parseInt(json.get("fixture_id").toString());
|
this.matchId = Integer.parseInt(json.get("fixture_id").toString());
|
||||||
@@ -73,14 +72,6 @@ public class APIFootballMatch extends BaseMatch {
|
|||||||
return this.round;
|
return this.round;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShowTable(boolean showTable) {
|
|
||||||
this.showTable = showTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getShowTable() {
|
|
||||||
return this.showTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int parseStatus(String statusShort) {
|
private int parseStatus(String statusShort) {
|
||||||
switch (statusShort) {
|
switch (statusShort) {
|
||||||
case "TBD":
|
case "TBD":
|
||||||
|
|||||||
@@ -12,9 +12,15 @@ public class APIFootballMatchesProvider {
|
|||||||
this.conn = APIFootballConnector.getAPIFootballConnectorInstance(season - 1);
|
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<>();
|
ArrayList<APIFootballMatch> apiFootballMatches = new ArrayList<>();
|
||||||
for (Object singleConfigObject : config) {
|
for (Object singleConfigObject : (JSONArray) matchdayConfig.get("matchesConfig")) {
|
||||||
JSONObject singleConfig = (JSONObject) singleConfigObject;
|
JSONObject singleConfig = (JSONObject) singleConfigObject;
|
||||||
String type = (String) singleConfig.get("type");
|
String type = (String) singleConfig.get("type");
|
||||||
boolean showTable = false;
|
boolean showTable = false;
|
||||||
@@ -29,7 +35,11 @@ public class APIFootballMatchesProvider {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
boolean finalShowTable = showTable;
|
boolean finalShowTable = showTable;
|
||||||
matches.forEach(apiFootballMatch -> apiFootballMatch.setShowTable(finalShowTable));
|
boolean finalKo = ko;
|
||||||
|
matches.forEach(apiFootballMatch -> {
|
||||||
|
apiFootballMatch.setShowTable(finalShowTable);
|
||||||
|
apiFootballMatch.setKoMatch(finalKo);
|
||||||
|
});
|
||||||
apiFootballMatches.addAll(matches);
|
apiFootballMatches.addAll(matches);
|
||||||
break;
|
break;
|
||||||
case "SingleMatch":
|
case "SingleMatch":
|
||||||
@@ -38,6 +48,7 @@ public class APIFootballMatchesProvider {
|
|||||||
APIFootballMatch match = conn.getMatchDataByLeagueAndMatchID(matchLeague, matchId);
|
APIFootballMatch match = conn.getMatchDataByLeagueAndMatchID(matchLeague, matchId);
|
||||||
showTable = (boolean) singleConfig.get("showTable");
|
showTable = (boolean) singleConfig.get("showTable");
|
||||||
match.setShowTable(showTable);
|
match.setShowTable(showTable);
|
||||||
|
match.setKoMatch(ko);
|
||||||
apiFootballMatches.add(match);
|
apiFootballMatches.add(match);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,11 @@ package de.jeyp91.tippliga;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import de.jeyp91.BaseMatch;
|
import de.jeyp91.BaseMatch;
|
||||||
import de.jeyp91.teamidmatcher.TeamIDMatcher;
|
import de.jeyp91.teamidmatcher.TeamIDMatcher;
|
||||||
import de.jeyp91.apifootball.APIFootballMatch;
|
import de.jeyp91.apifootball.APIFootballMatch;
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -20,8 +19,6 @@ public class TLWMatch extends BaseMatch{
|
|||||||
private String groupId = null;
|
private String groupId = null;
|
||||||
private String formulaHome = null;
|
private String formulaHome = null;
|
||||||
private String formulaGuest = null;
|
private String formulaGuest = null;
|
||||||
private Integer koMatch = 0;
|
|
||||||
private Integer showTable = null;
|
|
||||||
private String trend = null;
|
private String trend = null;
|
||||||
private Float odd1 = null;
|
private Float odd1 = null;
|
||||||
private Float oddX = null;
|
private Float oddX = null;
|
||||||
@@ -153,6 +150,14 @@ public class TLWMatch extends BaseMatch{
|
|||||||
this.rating = referenceMatch.rating;
|
this.rating = referenceMatch.rating;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TLWMatch(String formulaHome, String formulaGuest, String matchDateTime) {
|
||||||
|
this.teamIdHome = 0;
|
||||||
|
this.teamIdGuest = 0;
|
||||||
|
this.formulaHome = formulaHome;
|
||||||
|
this.formulaGuest = formulaGuest;
|
||||||
|
this.matchDatetime = matchDateTime;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getSeason() {
|
public Integer getSeason() {
|
||||||
return this.season;
|
return this.season;
|
||||||
}
|
}
|
||||||
@@ -165,21 +170,13 @@ public class TLWMatch extends BaseMatch{
|
|||||||
return this.matchNo;
|
return this.matchNo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getKoMatch() {
|
|
||||||
return this.koMatch;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGroupId() {
|
public String getGroupId() {
|
||||||
return this.groupId;
|
return this.groupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getShowTable() {
|
|
||||||
return this.showTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFormulaHome() {
|
public String getFormulaHome() {
|
||||||
String formula = "'D'";
|
String formula = "'D'";
|
||||||
if(this.teamIdHome != null) {
|
if(this.teamIdHome != null && this.teamIdHome != 0) {
|
||||||
return "''";
|
return "''";
|
||||||
}
|
}
|
||||||
else if (this.formulaHome != null) {
|
else if (this.formulaHome != null) {
|
||||||
@@ -190,7 +187,7 @@ public class TLWMatch extends BaseMatch{
|
|||||||
|
|
||||||
public String getFormulaGuest() {
|
public String getFormulaGuest() {
|
||||||
String formula = "'D'";
|
String formula = "'D'";
|
||||||
if(this.teamIdGuest != null) {
|
if(this.teamIdGuest != null && this.teamIdGuest != 0) {
|
||||||
return "''";
|
return "''";
|
||||||
}
|
}
|
||||||
else if (this.formulaGuest != null) {
|
else if (this.formulaGuest != null) {
|
||||||
@@ -260,10 +257,6 @@ public class TLWMatch extends BaseMatch{
|
|||||||
this.matchDatetime = matchDateTime;
|
this.matchDatetime = matchDateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShowTable(Boolean showTable) {
|
|
||||||
this.showTable = showTable ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateMatch(APIFootballMatch apiFootballMatch) {
|
public void updateMatch(APIFootballMatch apiFootballMatch) {
|
||||||
this.teamIdHome = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch, TeamIDMatcher.HOME);
|
this.teamIdHome = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch, TeamIDMatcher.HOME);
|
||||||
this.teamIdGuest = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch, TeamIDMatcher.GUEST);
|
this.teamIdGuest = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch, TeamIDMatcher.GUEST);
|
||||||
@@ -281,4 +274,24 @@ public class TLWMatch extends BaseMatch{
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isSameMatchPlaceholder (TLWMatch tlwMatch, TLWMatch placeholderConfigMatch) {
|
||||||
|
String placeholderConfigMatchDateTime = placeholderConfigMatch.getMatchDateTime();
|
||||||
|
String tlwMatchDateTime = tlwMatch.getMatchDateTime();
|
||||||
|
String placeholderConfigMatchFormulaHome = placeholderConfigMatch.getFormulaHome();
|
||||||
|
String tlwMatchFormulaHome = tlwMatch.getFormulaHome();
|
||||||
|
String placeholderConfigMatchFormulaGuest = placeholderConfigMatch.getFormulaGuest();
|
||||||
|
String tlwMatchFormulaGuest = tlwMatch.getFormulaGuest();
|
||||||
|
if(Objects.equals(tlwMatchDateTime, placeholderConfigMatchDateTime) &&
|
||||||
|
Objects.equals(tlwMatchFormulaHome, placeholderConfigMatchFormulaHome) &&
|
||||||
|
Objects.equals(tlwMatchFormulaGuest, placeholderConfigMatchFormulaGuest)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(Objects.equals(tlwMatchDateTime, placeholderConfigMatchDateTime) &&
|
||||||
|
Objects.equals(tlwMatch.getTeamIdHome(), null) &&
|
||||||
|
Objects.equals(tlwMatch.getTeamIdGuest(), null)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -29,8 +29,7 @@ public class TLWMatchdaysUpdater {
|
|||||||
this.matchdaysOriginal = conn.getMatchdays(String.valueOf(season), String.valueOf(league));
|
this.matchdaysOriginal = conn.getMatchdays(String.valueOf(season), String.valueOf(league));
|
||||||
this.matchdaysOriginal.sort(Comparator.comparing(TLWMatchday::getMatchday));
|
this.matchdaysOriginal.sort(Comparator.comparing(TLWMatchday::getMatchday));
|
||||||
|
|
||||||
TLWMatchdaysCreator creator = new TLWMatchdaysCreator(season, league, configPath);
|
this.matchdaysUpdated = conn.getUpdatedMatchdaysBasedOnMatches(String.valueOf(season), String.valueOf(league));
|
||||||
this.matchdaysUpdated = creator.getMatchdays();
|
|
||||||
this.matchdaysUpdated.sort(Comparator.comparing(TLWMatchday::getMatchday));
|
this.matchdaysUpdated.sort(Comparator.comparing(TLWMatchday::getMatchday));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,8 +105,7 @@ public class TLWMatchesManagerBase {
|
|||||||
return (int) date1.until(date2, ChronoUnit.DAYS);
|
return (int) date1.until(date2, ChronoUnit.DAYS);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TLWMatch getMatchingMatch(APIFootballMatch apiFootballMatch, ArrayList<TLWMatch> tlwMatches) throws NullPointerException{
|
protected TLWMatch getMatchingMatch(APIFootballMatch apiFootballMatch, ArrayList<TLWMatch> tlwMatches) {
|
||||||
int foundMatches = 0;
|
|
||||||
TLWMatch matchingMatch = null;
|
TLWMatch matchingMatch = null;
|
||||||
for(TLWMatch match : tlwMatches) {
|
for(TLWMatch match : tlwMatches) {
|
||||||
Integer apiTeamIdHome = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch, TeamIDMatcher.HOME);
|
Integer apiTeamIdHome = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch, TeamIDMatcher.HOME);
|
||||||
@@ -122,7 +121,6 @@ public class TLWMatchesManagerBase {
|
|||||||
apiTeamIdHome.equals(tlwTeamIdHome)
|
apiTeamIdHome.equals(tlwTeamIdHome)
|
||||||
&& apiTeamIdGuest.equals(tlwTeamIdGuest)
|
&& apiTeamIdGuest.equals(tlwTeamIdGuest)
|
||||||
) {
|
) {
|
||||||
foundMatches++;
|
|
||||||
matchingMatch = match;
|
matchingMatch = match;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class TLWMatchesResultsUpdater extends TLWMatchesManagerBase {
|
|||||||
int tlwMatchday = ((Long) ((JSONObject) singleMatchdayConfig).get("TLWMatchday")).intValue();
|
int tlwMatchday = ((Long) ((JSONObject) singleMatchdayConfig).get("TLWMatchday")).intValue();
|
||||||
JSONArray matchesConfig = (JSONArray) ((JSONObject) singleMatchdayConfig).get("matchesConfig");
|
JSONArray matchesConfig = (JSONArray) ((JSONObject) singleMatchdayConfig).get("matchesConfig");
|
||||||
|
|
||||||
ArrayList<APIFootballMatch> apiFootballMatches = apiFootballMatchesProvider.getAPIFootballMatchesFromConfig(matchesConfig);
|
ArrayList<APIFootballMatch> apiFootballMatches = apiFootballMatchesProvider.getAPIFootballMatchesFromConfig((JSONObject) singleMatchdayConfig);
|
||||||
|
|
||||||
ArrayList<TLWMatch> tlwMatchesOriginalMatchday = tippligaSQLConnector.getMatches(String.valueOf(this.season), String.valueOf(this.league), String.valueOf(tlwMatchday));
|
ArrayList<TLWMatch> tlwMatchesOriginalMatchday = tippligaSQLConnector.getMatches(String.valueOf(this.season), String.valueOf(this.league), String.valueOf(tlwMatchday));
|
||||||
ArrayList<TLWMatch> tlwMatchesUpdatedMatchday = new ArrayList<>();
|
ArrayList<TLWMatch> tlwMatchesUpdatedMatchday = new ArrayList<>();
|
||||||
@@ -90,7 +90,7 @@ public class TLWMatchesResultsUpdater extends TLWMatchesManagerBase {
|
|||||||
tlwMatch.setGoalsGuest(apiFootballMatch.getGoalsGuest());
|
tlwMatch.setGoalsGuest(apiFootballMatch.getGoalsGuest());
|
||||||
tlwMatch.setUpdateStatus(TLWMatch.COMPARISON.DIFFERENT_RESULT);
|
tlwMatch.setUpdateStatus(TLWMatch.COMPARISON.DIFFERENT_RESULT);
|
||||||
}
|
}
|
||||||
if(tlwMatch.getKoMatch() == 1 &&
|
if(tlwMatch.getKoMatch() &&
|
||||||
this.betKOType == 2 &&
|
this.betKOType == 2 &&
|
||||||
(!Objects.equals(tlwMatch.getGoalsOvertimeHome(), apiFootballMatch.getGoalsOvertimeHome())
|
(!Objects.equals(tlwMatch.getGoalsOvertimeHome(), apiFootballMatch.getGoalsOvertimeHome())
|
||||||
|| !Objects.equals(tlwMatch.getGoalsOvertimeGuest(), apiFootballMatch.getGoalsOvertimeGuest()))
|
|| !Objects.equals(tlwMatch.getGoalsOvertimeGuest(), apiFootballMatch.getGoalsOvertimeGuest()))
|
||||||
@@ -99,7 +99,7 @@ public class TLWMatchesResultsUpdater extends TLWMatchesManagerBase {
|
|||||||
tlwMatch.setGoalsOvertimeGuest(apiFootballMatch.getGoalsOvertimeGuest());
|
tlwMatch.setGoalsOvertimeGuest(apiFootballMatch.getGoalsOvertimeGuest());
|
||||||
tlwMatch.setUpdateStatus(TLWMatch.COMPARISON.DIFFERENT_RESULT);
|
tlwMatch.setUpdateStatus(TLWMatch.COMPARISON.DIFFERENT_RESULT);
|
||||||
}
|
}
|
||||||
if(tlwMatch.getKoMatch() == 1 &&
|
if(tlwMatch.getKoMatch() &&
|
||||||
(this.betKOType == 1 || this.betKOType == 3) &&
|
(this.betKOType == 1 || this.betKOType == 3) &&
|
||||||
(apiFootballMatch.getGoalsPenaltyHome() != null) &&
|
(apiFootballMatch.getGoalsPenaltyHome() != null) &&
|
||||||
(!Objects.equals(tlwMatch.getGoalsOvertimeHome(), apiFootballMatch.getGoalsPenaltyHome())
|
(!Objects.equals(tlwMatch.getGoalsOvertimeHome(), apiFootballMatch.getGoalsPenaltyHome())
|
||||||
@@ -109,7 +109,7 @@ public class TLWMatchesResultsUpdater extends TLWMatchesManagerBase {
|
|||||||
tlwMatch.setGoalsOvertimeGuest(apiFootballMatch.getGoalsPenaltyGuest());
|
tlwMatch.setGoalsOvertimeGuest(apiFootballMatch.getGoalsPenaltyGuest());
|
||||||
tlwMatch.setUpdateStatus(TLWMatch.COMPARISON.DIFFERENT_RESULT);
|
tlwMatch.setUpdateStatus(TLWMatch.COMPARISON.DIFFERENT_RESULT);
|
||||||
}
|
}
|
||||||
if(tlwMatch.getKoMatch() == 1 &&
|
if(tlwMatch.getKoMatch() &&
|
||||||
(this.betKOType == 1 || this.betKOType == 3) &&
|
(this.betKOType == 1 || this.betKOType == 3) &&
|
||||||
(apiFootballMatch.getGoalsPenaltyHome() == null) &&
|
(apiFootballMatch.getGoalsPenaltyHome() == null) &&
|
||||||
(!Objects.equals(tlwMatch.getGoalsOvertimeHome(), apiFootballMatch.getGoalsOvertimeHome())
|
(!Objects.equals(tlwMatch.getGoalsOvertimeHome(), apiFootballMatch.getGoalsOvertimeHome())
|
||||||
@@ -148,7 +148,7 @@ public class TLWMatchesResultsUpdater extends TLWMatchesManagerBase {
|
|||||||
"Ergebnis zu '" + matchUpdated.getGoalsHome() + ":" + matchUpdated.getGoalsGuest() + "'.\n";
|
"Ergebnis zu '" + matchUpdated.getGoalsHome() + ":" + matchUpdated.getGoalsGuest() + "'.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(matchOriginal.getKoMatch() == 1 && (!Objects.equals(matchOriginal.getGoalsOvertimeHome(), matchUpdated.getGoalsOvertimeHome())
|
if(matchOriginal.getKoMatch() && (!Objects.equals(matchOriginal.getGoalsOvertimeHome(), matchUpdated.getGoalsOvertimeHome())
|
||||||
|| !Objects.equals(matchOriginal.getGoalsOvertimeGuest(), matchUpdated.getGoalsOvertimeGuest()))) {
|
|| !Objects.equals(matchOriginal.getGoalsOvertimeGuest(), matchUpdated.getGoalsOvertimeGuest()))) {
|
||||||
this.beautifulInfo += beautifulInfoStart +
|
this.beautifulInfo += beautifulInfoStart +
|
||||||
"Ergebnis Nachspielzeit zu '" + matchUpdated.getGoalsOvertimeHome() + ":" + matchUpdated.getGoalsOvertimeGuest() + "'.\n";
|
"Ergebnis Nachspielzeit zu '" + matchUpdated.getGoalsOvertimeHome() + ":" + matchUpdated.getGoalsOvertimeGuest() + "'.\n";
|
||||||
@@ -157,8 +157,8 @@ public class TLWMatchesResultsUpdater extends TLWMatchesManagerBase {
|
|||||||
if(matchOriginal.getStatus().equals(TLWMatch.STATUS_PROVISIONAL_RESULT_AVAILABLE)
|
if(matchOriginal.getStatus().equals(TLWMatch.STATUS_PROVISIONAL_RESULT_AVAILABLE)
|
||||||
&& Objects.equals(matchOriginal.getGoalsHome(), matchUpdated.getGoalsHome())
|
&& Objects.equals(matchOriginal.getGoalsHome(), matchUpdated.getGoalsHome())
|
||||||
&& Objects.equals(matchOriginal.getGoalsGuest(), matchUpdated.getGoalsGuest())
|
&& Objects.equals(matchOriginal.getGoalsGuest(), matchUpdated.getGoalsGuest())
|
||||||
&& (matchOriginal.getKoMatch() == 0 || (
|
&& (!matchOriginal.getKoMatch() || (
|
||||||
matchOriginal.getKoMatch() == 1
|
matchOriginal.getKoMatch()
|
||||||
&& Objects.equals(matchOriginal.getGoalsOvertimeHome(), matchUpdated.getGoalsOvertimeHome())
|
&& Objects.equals(matchOriginal.getGoalsOvertimeHome(), matchUpdated.getGoalsOvertimeHome())
|
||||||
&& Objects.equals(matchOriginal.getGoalsOvertimeGuest(), matchUpdated.getGoalsOvertimeGuest())
|
&& Objects.equals(matchOriginal.getGoalsOvertimeGuest(), matchUpdated.getGoalsOvertimeGuest())
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import org.json.simple.JSONObject;
|
|||||||
|
|
||||||
import java.time.*;
|
import java.time.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
||||||
private static final Logger logger = LogManager.getLogger(TLWMatchesUpdaterFootball.class);
|
private static final Logger logger = LogManager.getLogger(TLWMatchesUpdaterFootball.class);
|
||||||
@@ -38,9 +40,8 @@ public class TLWMatchesUpdaterFootball 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(matchesConfig);
|
ArrayList<APIFootballMatch> apiFootballMatches = apiFootballMatchesProvider.getAPIFootballMatchesFromConfig((JSONObject) singleMatchdayConfig);
|
||||||
|
|
||||||
ArrayList<TLWMatch> tlwMatchesOriginalMatchday = tippligaSQLConnector.getMatches(String.valueOf(this.season), String.valueOf(this.league), String.valueOf(tlwMatchday));
|
ArrayList<TLWMatch> tlwMatchesOriginalMatchday = tippligaSQLConnector.getMatches(String.valueOf(this.season), String.valueOf(this.league), String.valueOf(tlwMatchday));
|
||||||
ArrayList<TLWMatch> tlwMatchesUpdatedMatchday = new ArrayList<>();
|
ArrayList<TLWMatch> tlwMatchesUpdatedMatchday = new ArrayList<>();
|
||||||
@@ -64,6 +65,10 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
|||||||
updateShowTable(tlwMatchesUpdatedMatchday, apiFootballMatches);
|
updateShowTable(tlwMatchesUpdatedMatchday, apiFootballMatches);
|
||||||
updateStatus(tlwMatchesUpdatedMatchday);
|
updateStatus(tlwMatchesUpdatedMatchday);
|
||||||
}
|
}
|
||||||
|
if(now.isBefore(firstMatchOriginal)) {
|
||||||
|
updateStatus(tlwMatchesUpdatedMatchday);
|
||||||
|
addPlaceholderMatches(tlwMatchesUpdatedMatchday, (JSONObject) singleMatchdayConfig);
|
||||||
|
}
|
||||||
|
|
||||||
this.tlwMatchesOriginal.addAll(tlwMatchesOriginalMatchday);
|
this.tlwMatchesOriginal.addAll(tlwMatchesOriginalMatchday);
|
||||||
this.tlwMatchesUpdated.addAll(tlwMatchesUpdatedMatchday);
|
this.tlwMatchesUpdated.addAll(tlwMatchesUpdatedMatchday);
|
||||||
@@ -135,6 +140,14 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
|||||||
"Spiel in Tabelle einberechnen zu '" + (matchUpdated.getShowTable() == 1 ? "falsch" : "wahr") + "'.\n";
|
"Spiel in Tabelle einberechnen zu '" + (matchUpdated.getShowTable() == 1 ? "falsch" : "wahr") + "'.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!matchOriginal.getKoMatch().equals(matchUpdated.getKoMatch())) {
|
||||||
|
updateString += updateStart +
|
||||||
|
"ko_match = '" + (matchUpdated.getKoMatch() ? "1" : "0") + "' " +
|
||||||
|
condition;
|
||||||
|
this.beautifulInfo += beautifulInfoStart +
|
||||||
|
"KO zu '" + (matchUpdated.getKoMatch() ? "wahr" : "falsch") + "'.\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return updateString;
|
return updateString;
|
||||||
}
|
}
|
||||||
@@ -145,30 +158,80 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
|||||||
ArrayList<APIFootballMatch> missingMatches = new ArrayList<>();
|
ArrayList<APIFootballMatch> missingMatches = new ArrayList<>();
|
||||||
|
|
||||||
for(APIFootballMatch apiFootballMatch : apiFootballMatches) {
|
for(APIFootballMatch apiFootballMatch : apiFootballMatches) {
|
||||||
try {
|
if(getMatchingMatch(apiFootballMatch, tlwMatches) == null) {
|
||||||
if(getMatchingMatch(apiFootballMatch, tlwMatches) == null) {
|
missingMatches.add(apiFootballMatch);
|
||||||
missingMatches.add(apiFootballMatch);
|
|
||||||
}
|
|
||||||
} catch (NullPointerException ignored) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (APIFootballMatch missingMatch : missingMatches) {
|
for (APIFootballMatch missingMatch : missingMatches) {
|
||||||
boolean done = false;
|
boolean done = false;
|
||||||
for(TLWMatch tlwMatch : tlwMatches) {
|
// update placeholder match based on matching match datetime
|
||||||
if(tlwMatch.getTeamIdHome() == 0 && tlwMatch.getTeamIdGuest() == 0) {
|
for (TLWMatch tlwMatch : tlwMatches) {
|
||||||
|
if ( tlwMatch.getTeamIdHome() == 0 && tlwMatch.getTeamIdGuest() == 0
|
||||||
|
&& Objects.equals(tlwMatch.getMatchDateTime(), missingMatch.getMatchDateTime().replace("T", " ").substring(0, 19))
|
||||||
|
&& !Objects.equals(tlwMatch.getFormulaHome(), "")
|
||||||
|
&& !Objects.equals(tlwMatch.getFormulaGuest(), "")) {
|
||||||
tlwMatch.updateMatch(missingMatch);
|
tlwMatch.updateMatch(missingMatch);
|
||||||
done = true;
|
done = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// update empty match
|
||||||
|
if(!done) {
|
||||||
|
for (TLWMatch tlwMatch : tlwMatches) {
|
||||||
|
if (tlwMatch.getTeamIdHome() == 0 && tlwMatch.getTeamIdGuest() == 0
|
||||||
|
&& Objects.equals(tlwMatch.getFormulaHome(), "")
|
||||||
|
&& Objects.equals(tlwMatch.getFormulaGuest(), "")) {
|
||||||
|
tlwMatch.updateMatch(missingMatch);
|
||||||
|
done = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if(!done) {
|
if(!done) {
|
||||||
logger.error("Could not add missing match: " + this.season + ", " + this.league + ", " + tlwMatches.get(0).getMatchday() + ", " + missingMatch.getTeamNameHome() + " - " + missingMatch.getTeamNameGuest());
|
logger.error("Could not add missing match: " + this.season + ", " + this.league + ", " + tlwMatches.get(0).getMatchday() + ", " + missingMatch.getTeamNameHome() + " - " + missingMatch.getTeamNameGuest());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addPlaceholderMatches(ArrayList<TLWMatch> tlwMatches,
|
||||||
|
JSONObject matchdayConfig) {
|
||||||
|
ArrayList<TLWMatch> placeholderMatches = new ArrayList<>();
|
||||||
|
ArrayList<TLWMatch> tlwMatchesCopy = new ArrayList<>(tlwMatches);
|
||||||
|
JSONArray matchesConfig = (JSONArray) matchdayConfig.get("matchesConfig");
|
||||||
|
for (Object singleMatchConfig : matchesConfig) {
|
||||||
|
// check if type placeholderSingleMatch
|
||||||
|
if(((JSONObject) singleMatchConfig).get("type").equals("PlaceholderSingleMatch")) {
|
||||||
|
String formulaHome = (String) ((JSONObject) singleMatchConfig).get("formulaHome");
|
||||||
|
String formulaGuest = (String) ((JSONObject) singleMatchConfig).get("formulaGuest");
|
||||||
|
String matchDateTime = (String) ((JSONObject) singleMatchConfig).get("placeholderDatetime");
|
||||||
|
TLWMatch placeholderMatch = new TLWMatch(formulaHome, formulaGuest, matchDateTime);
|
||||||
|
placeholderMatches.add(placeholderMatch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// filter placeholderMatches by checking if they are already in tlwMatches
|
||||||
|
Iterator<TLWMatch> placeholderIterator = placeholderMatches.iterator();
|
||||||
|
while (placeholderIterator.hasNext()) {
|
||||||
|
TLWMatch placeholderMatch = placeholderIterator.next();
|
||||||
|
Iterator<TLWMatch> tlwMatchIterator = tlwMatchesCopy.iterator();
|
||||||
|
while (tlwMatchIterator.hasNext()) {
|
||||||
|
TLWMatch tlwMatch = tlwMatchIterator.next();
|
||||||
|
if (TLWMatch.isSameMatchPlaceholder(tlwMatch, placeholderMatch)) {
|
||||||
|
tlwMatchIterator.remove();
|
||||||
|
placeholderIterator.remove();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// check if total number of matches is not too high
|
||||||
|
if(tlwMatches.size() + placeholderMatches.size() > (Integer.parseInt(matchdayConfig.get("numberOfMatches").toString()))) {
|
||||||
|
logger.error("Too many matches in config: " + this.season + ", " + this.league + ", " + tlwMatches.get(0).getMatchday());
|
||||||
|
} else {
|
||||||
|
// add placeholderMatches to tlwMatches
|
||||||
|
tlwMatches.addAll(placeholderMatches);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateMatchDateTimes(
|
private void updateMatchDateTimes(
|
||||||
ArrayList<TLWMatch> tlwMatches,
|
ArrayList<TLWMatch> tlwMatches,
|
||||||
ArrayList<APIFootballMatch> apiFootballMatches)
|
ArrayList<APIFootballMatch> apiFootballMatches)
|
||||||
@@ -195,10 +258,13 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
|||||||
if(earliestDate.isAfter(now)) {
|
if(earliestDate.isAfter(now)) {
|
||||||
for(TLWMatch match : matches) {
|
for(TLWMatch match : matches) {
|
||||||
LocalDateTime date = TLWMatchesManagerBase.getDate(match);
|
LocalDateTime date = TLWMatchesManagerBase.getDate(match);
|
||||||
if (getDaysDifference(earliestDate, date) == 0) {
|
int daysDifference = TLWMatchesManagerBase.getDaysDifference(earliestDate, date);
|
||||||
|
if (daysDifference == 0) {
|
||||||
match.setStatus(0);
|
match.setStatus(0);
|
||||||
} else {
|
} else if (daysDifference > 0 && daysDifference < 7) {
|
||||||
match.setStatus(-1);
|
match.setStatus(-1);
|
||||||
|
} else {
|
||||||
|
match.setStatus(-2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -213,7 +279,23 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
|||||||
try {
|
try {
|
||||||
TLWMatch tlwMatch = getMatchingMatch(apiFootballMatch, tlwMatchesCopy);
|
TLWMatch tlwMatch = getMatchingMatch(apiFootballMatch, tlwMatchesCopy);
|
||||||
tlwMatchesCopy.remove(tlwMatch);
|
tlwMatchesCopy.remove(tlwMatch);
|
||||||
tlwMatch.setShowTable(apiFootballMatch.getShowTable());
|
tlwMatch.setShowTable(apiFootballMatch.getShowTable() == 0);
|
||||||
|
} catch (NullPointerException ignored) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateKo(
|
||||||
|
ArrayList<TLWMatch> tlwMatches,
|
||||||
|
ArrayList<APIFootballMatch> apiFootballMatches)
|
||||||
|
{
|
||||||
|
ArrayList<TLWMatch> tlwMatchesCopy = new ArrayList<>(tlwMatches);
|
||||||
|
for(APIFootballMatch apiFootballMatch : apiFootballMatches) {
|
||||||
|
try {
|
||||||
|
TLWMatch tlwMatch = getMatchingMatch(apiFootballMatch, tlwMatchesCopy);
|
||||||
|
tlwMatchesCopy.remove(tlwMatch);
|
||||||
|
tlwMatch.setKoMatch(apiFootballMatch.getKoMatch());
|
||||||
} catch (NullPointerException ignored) {
|
} catch (NullPointerException ignored) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,6 +140,52 @@ public class TippligaSQLConnector {
|
|||||||
return matchdays;
|
return matchdays;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<TLWMatchday> getUpdatedMatchdaysBasedOnMatches(String season, String league) {
|
||||||
|
String queryString = """
|
||||||
|
SELECT
|
||||||
|
d1.season,
|
||||||
|
d1.league,
|
||||||
|
d1.matchday,
|
||||||
|
d1.status,
|
||||||
|
d1.delivery_date,
|
||||||
|
min(STR_TO_DATE(d2.match_datetime, '%Y-%m-%d %H:%i:%s')) as delivery_date_2,
|
||||||
|
min(STR_TO_DATE(d3.match_datetime, '%Y-%m-%d %H:%i:%s')) as delivery_date_3,
|
||||||
|
d1.matchday_name,
|
||||||
|
d1.matches
|
||||||
|
FROM (
|
||||||
|
SELECT
|
||||||
|
md.season,
|
||||||
|
md.league,
|
||||||
|
md.matchday,
|
||||||
|
md.status,
|
||||||
|
min(STR_TO_DATE(ma.match_datetime, '%Y-%m-%d %H:%i:%s')) AS delivery_date,
|
||||||
|
md.matchday_name,
|
||||||
|
md.matches
|
||||||
|
FROM phpbb_footb_matchdays md
|
||||||
|
LEFT JOIN phpbb_footb_matches ma ON (md.season = ma.season AND md.league = ma.league AND md.matchday = ma.matchday)
|
||||||
|
WHERE md.season =""" + " " + season + " " + """
|
||||||
|
AND md.league =""" + " " + league + " " + """
|
||||||
|
GROUP BY md.season, md.league, md.matchday
|
||||||
|
) AS d1
|
||||||
|
LEFT JOIN phpbb_footb_matches d2 ON (d1.season = d2.season AND d1.league = d2.league AND d1.matchday = d2.matchday
|
||||||
|
AND DATEDIFF(DATE(STR_TO_DATE(d2.match_datetime, '%Y-%m-%d %H:%i:%s')), DATE(d1.delivery_date)) > 0)
|
||||||
|
LEFT JOIN phpbb_footb_matches d3 ON (d1.season = d3.season AND d1.league = d3.league AND d1.matchday = d3.matchday
|
||||||
|
AND DATEDIFF(DATE(STR_TO_DATE(d3.match_datetime, '%Y-%m-%d %H:%i:%s')), DATE(d1.delivery_date)) > 6)
|
||||||
|
GROUP BY d1.season, d1.league, d1.matchday;
|
||||||
|
""";
|
||||||
|
|
||||||
|
ArrayList<TLWMatchday> matchdays = new ArrayList<>();
|
||||||
|
ResultSet rset = executeQuery(queryString);
|
||||||
|
try {
|
||||||
|
while (rset.next()) {
|
||||||
|
matchdays.add(new TLWMatchday(rset));
|
||||||
|
}
|
||||||
|
} catch (SQLException throwables) {
|
||||||
|
throwables.printStackTrace();
|
||||||
|
}
|
||||||
|
return matchdays;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getForumId(String forumName, int parentId) {
|
public Integer getForumId(String forumName, int parentId) {
|
||||||
String queryString = "SELECT forum_id FROM phpbb_forums WHERE forum_name = \"" + forumName + "\" AND parent_id = " + parentId + ";";
|
String queryString = "SELECT forum_id FROM phpbb_forums WHERE forum_name = \"" + forumName + "\" AND parent_id = " + parentId + ";";
|
||||||
ResultSet rset = executeQuery(queryString);
|
ResultSet rset = executeQuery(queryString);
|
||||||
|
|||||||
Reference in New Issue
Block a user