Add several improvements for EM
This commit is contained in:
@@ -6,8 +6,8 @@ apply plugin: 'java'
|
||||
apply plugin: 'application'
|
||||
|
||||
mainClassName = 'App'
|
||||
sourceCompatibility = 11
|
||||
targetCompatibility = 11
|
||||
sourceCompatibility = 15
|
||||
targetCompatibility = 15
|
||||
version = '1.0'
|
||||
compileJava.options.encoding = 'UTF-8'
|
||||
compileTestJava.options.encoding = 'UTF-8'
|
||||
|
||||
@@ -28,6 +28,8 @@ public abstract class BaseMatch {
|
||||
protected Integer matchday = null;
|
||||
protected String matchDatetime = null;
|
||||
protected Integer status = null;
|
||||
protected Integer koMatch = 0;
|
||||
protected Integer showTable = 0;
|
||||
protected COMPARISON updateStatus = COMPARISON.IDENTICAL;
|
||||
|
||||
public Integer getMatchday() {
|
||||
@@ -86,6 +88,22 @@ public abstract class BaseMatch {
|
||||
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 COMPARISON getUpdateStatus() {
|
||||
|
||||
@@ -11,7 +11,6 @@ public class APIFootballMatch extends BaseMatch {
|
||||
private String teamNameHome;
|
||||
private String teamNameGuest;
|
||||
private String round;
|
||||
private Boolean showTable = null;
|
||||
|
||||
public APIFootballMatch(JSONObject json, int season) throws Exception {
|
||||
this.matchId = Integer.parseInt(json.get("fixture_id").toString());
|
||||
@@ -73,14 +72,6 @@ public class APIFootballMatch extends BaseMatch {
|
||||
return this.round;
|
||||
}
|
||||
|
||||
public void setShowTable(boolean showTable) {
|
||||
this.showTable = showTable;
|
||||
}
|
||||
|
||||
public Boolean getShowTable() {
|
||||
return this.showTable;
|
||||
}
|
||||
|
||||
private int parseStatus(String statusShort) {
|
||||
switch (statusShort) {
|
||||
case "TBD":
|
||||
|
||||
@@ -12,9 +12,15 @@ public class APIFootballMatchesProvider {
|
||||
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<>();
|
||||
for (Object singleConfigObject : config) {
|
||||
for (Object singleConfigObject : (JSONArray) matchdayConfig.get("matchesConfig")) {
|
||||
JSONObject singleConfig = (JSONObject) singleConfigObject;
|
||||
String type = (String) singleConfig.get("type");
|
||||
boolean showTable = false;
|
||||
@@ -29,7 +35,11 @@ public class APIFootballMatchesProvider {
|
||||
e.printStackTrace();
|
||||
}
|
||||
boolean finalShowTable = showTable;
|
||||
matches.forEach(apiFootballMatch -> apiFootballMatch.setShowTable(finalShowTable));
|
||||
boolean finalKo = ko;
|
||||
matches.forEach(apiFootballMatch -> {
|
||||
apiFootballMatch.setShowTable(finalShowTable);
|
||||
apiFootballMatch.setKoMatch(finalKo);
|
||||
});
|
||||
apiFootballMatches.addAll(matches);
|
||||
break;
|
||||
case "SingleMatch":
|
||||
@@ -38,6 +48,7 @@ public class APIFootballMatchesProvider {
|
||||
APIFootballMatch match = conn.getMatchDataByLeagueAndMatchID(matchLeague, matchId);
|
||||
showTable = (boolean) singleConfig.get("showTable");
|
||||
match.setShowTable(showTable);
|
||||
match.setKoMatch(ko);
|
||||
apiFootballMatches.add(match);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2,12 +2,11 @@ package de.jeyp91.tippliga;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Objects;
|
||||
|
||||
import de.jeyp91.BaseMatch;
|
||||
import de.jeyp91.teamidmatcher.TeamIDMatcher;
|
||||
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 formulaHome = null;
|
||||
private String formulaGuest = null;
|
||||
private Integer koMatch = 0;
|
||||
private Integer showTable = null;
|
||||
private String trend = null;
|
||||
private Float odd1 = null;
|
||||
private Float oddX = null;
|
||||
@@ -153,6 +150,14 @@ public class TLWMatch extends BaseMatch{
|
||||
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() {
|
||||
return this.season;
|
||||
}
|
||||
@@ -165,21 +170,13 @@ public class TLWMatch extends BaseMatch{
|
||||
return this.matchNo;
|
||||
}
|
||||
|
||||
public Integer getKoMatch() {
|
||||
return this.koMatch;
|
||||
}
|
||||
|
||||
public String getGroupId() {
|
||||
return this.groupId;
|
||||
}
|
||||
|
||||
public Integer getShowTable() {
|
||||
return this.showTable;
|
||||
}
|
||||
|
||||
public String getFormulaHome() {
|
||||
String formula = "'D'";
|
||||
if(this.teamIdHome != null) {
|
||||
if(this.teamIdHome != null && this.teamIdHome != 0) {
|
||||
return "''";
|
||||
}
|
||||
else if (this.formulaHome != null) {
|
||||
@@ -190,7 +187,7 @@ public class TLWMatch extends BaseMatch{
|
||||
|
||||
public String getFormulaGuest() {
|
||||
String formula = "'D'";
|
||||
if(this.teamIdGuest != null) {
|
||||
if(this.teamIdGuest != null && this.teamIdGuest != 0) {
|
||||
return "''";
|
||||
}
|
||||
else if (this.formulaGuest != null) {
|
||||
@@ -260,10 +257,6 @@ public class TLWMatch extends BaseMatch{
|
||||
this.matchDatetime = matchDateTime;
|
||||
}
|
||||
|
||||
public void setShowTable(Boolean showTable) {
|
||||
this.showTable = showTable ? 0 : 1;
|
||||
}
|
||||
|
||||
public void updateMatch(APIFootballMatch apiFootballMatch) {
|
||||
this.teamIdHome = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch, TeamIDMatcher.HOME);
|
||||
this.teamIdGuest = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch, TeamIDMatcher.GUEST);
|
||||
@@ -281,4 +274,24 @@ public class TLWMatch extends BaseMatch{
|
||||
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.sort(Comparator.comparing(TLWMatchday::getMatchday));
|
||||
|
||||
TLWMatchdaysCreator creator = new TLWMatchdaysCreator(season, league, configPath);
|
||||
this.matchdaysUpdated = creator.getMatchdays();
|
||||
this.matchdaysUpdated = conn.getUpdatedMatchdaysBasedOnMatches(String.valueOf(season), String.valueOf(league));
|
||||
this.matchdaysUpdated.sort(Comparator.comparing(TLWMatchday::getMatchday));
|
||||
}
|
||||
|
||||
|
||||
@@ -105,8 +105,7 @@ public class TLWMatchesManagerBase {
|
||||
return (int) date1.until(date2, ChronoUnit.DAYS);
|
||||
}
|
||||
|
||||
protected TLWMatch getMatchingMatch(APIFootballMatch apiFootballMatch, ArrayList<TLWMatch> tlwMatches) throws NullPointerException{
|
||||
int foundMatches = 0;
|
||||
protected TLWMatch getMatchingMatch(APIFootballMatch apiFootballMatch, ArrayList<TLWMatch> tlwMatches) {
|
||||
TLWMatch matchingMatch = null;
|
||||
for(TLWMatch match : tlwMatches) {
|
||||
Integer apiTeamIdHome = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch, TeamIDMatcher.HOME);
|
||||
@@ -122,7 +121,6 @@ public class TLWMatchesManagerBase {
|
||||
apiTeamIdHome.equals(tlwTeamIdHome)
|
||||
&& apiTeamIdGuest.equals(tlwTeamIdGuest)
|
||||
) {
|
||||
foundMatches++;
|
||||
matchingMatch = match;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class TLWMatchesResultsUpdater extends TLWMatchesManagerBase {
|
||||
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> tlwMatchesUpdatedMatchday = new ArrayList<>();
|
||||
@@ -90,7 +90,7 @@ public class TLWMatchesResultsUpdater extends TLWMatchesManagerBase {
|
||||
tlwMatch.setGoalsGuest(apiFootballMatch.getGoalsGuest());
|
||||
tlwMatch.setUpdateStatus(TLWMatch.COMPARISON.DIFFERENT_RESULT);
|
||||
}
|
||||
if(tlwMatch.getKoMatch() == 1 &&
|
||||
if(tlwMatch.getKoMatch() &&
|
||||
this.betKOType == 2 &&
|
||||
(!Objects.equals(tlwMatch.getGoalsOvertimeHome(), apiFootballMatch.getGoalsOvertimeHome())
|
||||
|| !Objects.equals(tlwMatch.getGoalsOvertimeGuest(), apiFootballMatch.getGoalsOvertimeGuest()))
|
||||
@@ -99,7 +99,7 @@ public class TLWMatchesResultsUpdater extends TLWMatchesManagerBase {
|
||||
tlwMatch.setGoalsOvertimeGuest(apiFootballMatch.getGoalsOvertimeGuest());
|
||||
tlwMatch.setUpdateStatus(TLWMatch.COMPARISON.DIFFERENT_RESULT);
|
||||
}
|
||||
if(tlwMatch.getKoMatch() == 1 &&
|
||||
if(tlwMatch.getKoMatch() &&
|
||||
(this.betKOType == 1 || this.betKOType == 3) &&
|
||||
(apiFootballMatch.getGoalsPenaltyHome() != null) &&
|
||||
(!Objects.equals(tlwMatch.getGoalsOvertimeHome(), apiFootballMatch.getGoalsPenaltyHome())
|
||||
@@ -109,7 +109,7 @@ public class TLWMatchesResultsUpdater extends TLWMatchesManagerBase {
|
||||
tlwMatch.setGoalsOvertimeGuest(apiFootballMatch.getGoalsPenaltyGuest());
|
||||
tlwMatch.setUpdateStatus(TLWMatch.COMPARISON.DIFFERENT_RESULT);
|
||||
}
|
||||
if(tlwMatch.getKoMatch() == 1 &&
|
||||
if(tlwMatch.getKoMatch() &&
|
||||
(this.betKOType == 1 || this.betKOType == 3) &&
|
||||
(apiFootballMatch.getGoalsPenaltyHome() == null) &&
|
||||
(!Objects.equals(tlwMatch.getGoalsOvertimeHome(), apiFootballMatch.getGoalsOvertimeHome())
|
||||
@@ -148,7 +148,7 @@ public class TLWMatchesResultsUpdater extends TLWMatchesManagerBase {
|
||||
"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()))) {
|
||||
this.beautifulInfo += beautifulInfoStart +
|
||||
"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)
|
||||
&& Objects.equals(matchOriginal.getGoalsHome(), matchUpdated.getGoalsHome())
|
||||
&& Objects.equals(matchOriginal.getGoalsGuest(), matchUpdated.getGoalsGuest())
|
||||
&& (matchOriginal.getKoMatch() == 0 || (
|
||||
matchOriginal.getKoMatch() == 1
|
||||
&& (!matchOriginal.getKoMatch() || (
|
||||
matchOriginal.getKoMatch()
|
||||
&& Objects.equals(matchOriginal.getGoalsOvertimeHome(), matchUpdated.getGoalsOvertimeHome())
|
||||
&& Objects.equals(matchOriginal.getGoalsOvertimeGuest(), matchUpdated.getGoalsOvertimeGuest())
|
||||
))
|
||||
|
||||
@@ -12,6 +12,8 @@ import org.json.simple.JSONObject;
|
||||
|
||||
import java.time.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Objects;
|
||||
|
||||
public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
||||
private static final Logger logger = LogManager.getLogger(TLWMatchesUpdaterFootball.class);
|
||||
@@ -38,9 +40,8 @@ public class TLWMatchesUpdaterFootball 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(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> tlwMatchesUpdatedMatchday = new ArrayList<>();
|
||||
@@ -64,6 +65,10 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
||||
updateShowTable(tlwMatchesUpdatedMatchday, apiFootballMatches);
|
||||
updateStatus(tlwMatchesUpdatedMatchday);
|
||||
}
|
||||
if(now.isBefore(firstMatchOriginal)) {
|
||||
updateStatus(tlwMatchesUpdatedMatchday);
|
||||
addPlaceholderMatches(tlwMatchesUpdatedMatchday, (JSONObject) singleMatchdayConfig);
|
||||
}
|
||||
|
||||
this.tlwMatchesOriginal.addAll(tlwMatchesOriginalMatchday);
|
||||
this.tlwMatchesUpdated.addAll(tlwMatchesUpdatedMatchday);
|
||||
@@ -135,6 +140,14 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
||||
"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;
|
||||
}
|
||||
@@ -145,30 +158,80 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
||||
ArrayList<APIFootballMatch> missingMatches = new ArrayList<>();
|
||||
|
||||
for(APIFootballMatch apiFootballMatch : apiFootballMatches) {
|
||||
try {
|
||||
if(getMatchingMatch(apiFootballMatch, tlwMatches) == null) {
|
||||
missingMatches.add(apiFootballMatch);
|
||||
}
|
||||
} catch (NullPointerException ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for (APIFootballMatch missingMatch : missingMatches) {
|
||||
boolean done = false;
|
||||
for(TLWMatch tlwMatch : tlwMatches) {
|
||||
if(tlwMatch.getTeamIdHome() == 0 && tlwMatch.getTeamIdGuest() == 0) {
|
||||
// update placeholder match based on matching match datetime
|
||||
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);
|
||||
done = true;
|
||||
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) {
|
||||
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(
|
||||
ArrayList<TLWMatch> tlwMatches,
|
||||
ArrayList<APIFootballMatch> apiFootballMatches)
|
||||
@@ -195,10 +258,13 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
||||
if(earliestDate.isAfter(now)) {
|
||||
for(TLWMatch match : matches) {
|
||||
LocalDateTime date = TLWMatchesManagerBase.getDate(match);
|
||||
if (getDaysDifference(earliestDate, date) == 0) {
|
||||
int daysDifference = TLWMatchesManagerBase.getDaysDifference(earliestDate, date);
|
||||
if (daysDifference == 0) {
|
||||
match.setStatus(0);
|
||||
} else {
|
||||
} else if (daysDifference > 0 && daysDifference < 7) {
|
||||
match.setStatus(-1);
|
||||
} else {
|
||||
match.setStatus(-2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -213,7 +279,23 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
||||
try {
|
||||
TLWMatch tlwMatch = getMatchingMatch(apiFootballMatch, tlwMatchesCopy);
|
||||
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) {
|
||||
|
||||
}
|
||||
|
||||
@@ -140,6 +140,52 @@ public class TippligaSQLConnector {
|
||||
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) {
|
||||
String queryString = "SELECT forum_id FROM phpbb_forums WHERE forum_name = \"" + forumName + "\" AND parent_id = " + parentId + ";";
|
||||
ResultSet rset = executeQuery(queryString);
|
||||
|
||||
Reference in New Issue
Block a user