Updates for season 2022
This commit is contained in:
@@ -62,12 +62,12 @@ public class App {
|
||||
break;
|
||||
case "APIFootballUpdater":
|
||||
APIFootballUpdater apiFootballUpdater = new APIFootballUpdater();
|
||||
apiFootballUpdater.updateAllFixtures();
|
||||
apiFootballUpdater.updateAllRounds();
|
||||
apiFootballUpdater.updateAllFixtures(season);
|
||||
apiFootballUpdater.updateAllRounds(season);
|
||||
break;
|
||||
case "MatchesListGistUpdater":
|
||||
MatchesListForumUpdater matchesListForumUpdater = new MatchesListForumUpdater();
|
||||
matchesListForumUpdater.updateAllLeagues();
|
||||
MatchesListForumUpdater matchesListForumUpdater = new MatchesListForumUpdater(season);
|
||||
matchesListForumUpdater.updateAllLeagues(season);
|
||||
break;
|
||||
case "PostChecksum":
|
||||
TippligaSQLConnector con = TippligaSQLConnector.getInstance();
|
||||
|
||||
@@ -27,8 +27,8 @@ public class ResourceProvider {
|
||||
return array;
|
||||
}
|
||||
|
||||
public static JSONArray getLigenConfig() {
|
||||
return getJSONArrayFromResource("Tippliga/Ligen.json");
|
||||
public static JSONArray getLigenConfig(int season) {
|
||||
return getJSONArrayFromResource("Tippliga/" + season + "_Ligen.json");
|
||||
}
|
||||
|
||||
public static JSONArray getTeamIDMatcherConfig() {
|
||||
|
||||
@@ -47,15 +47,15 @@ public class APIFootballUpdater {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAllFixtures() {
|
||||
HashSet<Integer> leagues = getLeagues();
|
||||
public void updateAllFixtures(int season) {
|
||||
HashSet<Integer> leagues = getLeagues(season);
|
||||
for (Integer league : leagues) {
|
||||
updateFixtures(league);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAllRounds() {
|
||||
HashSet<Integer> leagues = getLeagues();
|
||||
public void updateAllRounds(int season) {
|
||||
HashSet<Integer> leagues = getLeagues(season);
|
||||
for (Integer league : leagues) {
|
||||
updateRounds(league);
|
||||
}
|
||||
@@ -131,8 +131,8 @@ public class APIFootballUpdater {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public HashSet<Integer> getLeagues() {
|
||||
JSONArray leaguesArray = ResourceProvider.getLigenConfig();
|
||||
public HashSet<Integer> getLeagues(int season) {
|
||||
JSONArray leaguesArray = ResourceProvider.getLigenConfig(season);
|
||||
HashSet<Integer> leagues = new HashSet<>();
|
||||
for (Object leagueObject : leaguesArray) {
|
||||
JSONObject leagueJSONObject = (JSONObject) leagueObject;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class TLWMatchdaysCreator {
|
||||
this.season = season;
|
||||
this.league = league;
|
||||
|
||||
TLWMatchesCreatorFootball matchesCreator = new TLWMatchesCreatorFootball(2021, 1, configPath);
|
||||
TLWMatchesCreatorFootball matchesCreator = new TLWMatchesCreatorFootball(season, 1, configPath);
|
||||
this.matches = matchesCreator.getMatches();
|
||||
|
||||
TippligaConfigProvider prov = new TippligaConfigProvider(season);
|
||||
|
||||
@@ -32,6 +32,7 @@ public class TLWMatchesCreatorFootball extends TLWMatchesCreatorBase {
|
||||
this.config = prov.getTippligaConfig(configFileName);
|
||||
|
||||
this.numberOfMatchdays = ((Long) this.config.get("numberOfMatchdays")).intValue();
|
||||
this.matchesPerMatchday = ((Long) this.config.get("matchesPerMatchday")).intValue();
|
||||
this.matchdayConfig = (JSONArray) this.config.get("matchdayConfig");
|
||||
this.ko = ((Long) this.config.get("ko")).intValue();
|
||||
String deliveryDateMode = this.config.containsKey("deliveryDateMode") ? this.config.get("deliveryDateMode").toString() : "";
|
||||
@@ -46,11 +47,6 @@ public class TLWMatchesCreatorFootball extends TLWMatchesCreatorBase {
|
||||
JSONArray matchesConfig = (JSONArray)((JSONObject) this.matchdayConfig.get(i)).get("matchesConfig");
|
||||
ArrayList<APIFootballMatch> apiFootballMatchesForMatchday = getAPIFootballMatchesForMatchday(matchesConfig);
|
||||
|
||||
int tempNumberOfMatchesBackup = this.matchesPerMatchday;
|
||||
if(((JSONObject) this.matchdayConfig.get(i)).containsKey("numberOfMatches")) {
|
||||
this.matchesPerMatchday = ((Long) ((JSONObject) this.matchdayConfig.get(i)).get("numberOfMatches")).intValue();
|
||||
}
|
||||
|
||||
int matchdayMatchCounter = 0;
|
||||
|
||||
// Use first matchtime because API Football always returns matches sorted by date
|
||||
@@ -74,7 +70,15 @@ public class TLWMatchesCreatorFootball extends TLWMatchesCreatorBase {
|
||||
}
|
||||
|
||||
// Add empty missing matches
|
||||
for(int j = matchdayMatchCounter; j < this.matchesPerMatchday; j++) {
|
||||
int matchesPerMatchdayTemp = 0;
|
||||
if(this.matchesPerMatchday != 0) {
|
||||
matchesPerMatchdayTemp = this.matchesPerMatchday;
|
||||
} else {
|
||||
if(((JSONObject) this.matchdayConfig.get(i)).containsKey("numberOfMatches")) {
|
||||
matchesPerMatchdayTemp = ((Long) ((JSONObject) this.matchdayConfig.get(i)).get("numberOfMatches")).intValue();
|
||||
}
|
||||
}
|
||||
for(int j = matchdayMatchCounter; j < matchesPerMatchdayTemp; j++) {
|
||||
String matchDatetime = "";
|
||||
if(apiFootballMatchesForMatchday.size() > 0) {
|
||||
matchDatetime = this.TLWMatches.get(this.TLWMatches.size() - 1).getMatchDateTime();
|
||||
@@ -86,10 +90,6 @@ public class TLWMatchesCreatorFootball extends TLWMatchesCreatorBase {
|
||||
this.nextMatchNo++;
|
||||
this.TLWMatches.add(new TLWMatch(this.season, this.league, TLWMatchday, matchNo, matchDatetime, 0, this.ko));
|
||||
}
|
||||
|
||||
if(((JSONObject) this.matchdayConfig.get(i)).containsKey("numberOfMatches")) {
|
||||
this.matchesPerMatchday = tempNumberOfMatchesBackup;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ public class TLWTeamsCreator {
|
||||
String getGroup(Integer teamId) {
|
||||
for(TLWMatch match: matches) {
|
||||
if(teamId.equals(match.getTeamIdHome()) || teamId.equals(match.getTeamIdGuest())) {
|
||||
return match.getGroupId();
|
||||
return match.getGroupId() != null ? match.getGroupId() : "";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
|
||||
@@ -8,28 +8,32 @@ import java.util.HashSet;
|
||||
public class MatchesListForumUpdater {
|
||||
private HashSet<Integer> leagues;
|
||||
|
||||
public MatchesListForumUpdater() {
|
||||
this.leagues = new APIFootballUpdater().getLeagues();
|
||||
public MatchesListForumUpdater(int season) {
|
||||
this.leagues = new APIFootballUpdater().getLeagues(season);
|
||||
}
|
||||
|
||||
public void updateAllLeagues() {
|
||||
public void updateAllLeagues(int season) {
|
||||
for(Integer league : this.leagues) {
|
||||
updateLeague(league);
|
||||
updateLeague(season, league);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateLeague(int league) {
|
||||
public void updateLeague(int season, int league) {
|
||||
MatchesListCreator creator = new MatchesListCreator(league);
|
||||
String content = creator.getMatchesBeautiful();
|
||||
String contentWithCodeBBCode = "<r><CODE><s>[code]</s>" + content + "<e>[/code]</e></CODE></r>";
|
||||
int postId = getPostId(creator.getCountry(), creator.getLeagueName());
|
||||
int postId = getPostId(season, creator.getCountry(), creator.getLeagueName());
|
||||
TippligaSQLConnector con = TippligaSQLConnector.getInstance();
|
||||
con.updatePost(postId, contentWithCodeBBCode);
|
||||
}
|
||||
|
||||
private Integer getPostId(String country, String league) {
|
||||
String query = "SELECT post_id FROM phpbb_posts WHERE post_subject = '" + country + " " + league + "';";
|
||||
private Integer getPostId(int season, String country, String league) {
|
||||
TippligaSQLConnector con = TippligaSQLConnector.getInstance();
|
||||
Integer adminForumId = con.getForumId("Admin");
|
||||
Integer tippligaConfigForumId = con.getForumId("Tippliga-Config", adminForumId);
|
||||
Integer seasonForumId = con.getForumId(String.valueOf(season), tippligaConfigForumId);
|
||||
Integer leagueForumId = con.getForumId("Ligen", seasonForumId);
|
||||
String query = "SELECT post_id FROM phpbb_posts WHERE post_subject = '" + country + " " + league + "' AND forum_id = " + leagueForumId + ";";
|
||||
ResultSet rset = con.executeQuery(query);
|
||||
Integer postId = null;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user