Updates for season 2022

This commit is contained in:
Julian Arndt
2021-07-19 15:05:48 +02:00
parent c959d62116
commit 2f0385f1f5
16 changed files with 251 additions and 84 deletions

View File

@@ -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();

View File

@@ -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() {

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;
}
}
}

View File

@@ -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 "";

View File

@@ -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 {

View File

@@ -0,0 +1,72 @@
[
{
"country": "Germany",
"name": "Bundesliga 1",
"league_id": 3510
},
{
"country": "Germany",
"name": "Bundesliga 2",
"league_id": 3509
},
{
"country": "Germany",
"name": "Liga 3",
"league_id": 3520
},
{
"country": "Germany",
"name": "Regionalliga - SudWest",
"league_id": 3582
},
{
"country": "Germany",
"name": "Regionalliga - Bayern",
"league_id": 3584
},
{
"country": "Germany",
"name": "DFB Pokal",
"league_id": 3532
},
{
"country": "Germany",
"name": "U19 Bundesliga",
"league_id": 3555
},
{
"country": "Germany",
"name": "Women Bundesliga",
"league_id": 3541
},
{
"country": "England",
"name": "Premier League",
"league_id": 3456
},
{
"country": "Spain",
"name": "Primera Division",
"league_id": 3513
},
{
"country": "Italy",
"name": "Serie A",
"league_id": 3576
},
{
"country": "France",
"name": "Ligue 1",
"league_id": 3506
},
{
"country": "World",
"name": "UEFA Champions League",
"league_id": 3431
},
{
"country": "World",
"name": "UEFA Europa Conference League",
"league_id": 3490
}
]

View File

@@ -833,5 +833,55 @@
"teamname": "Nordmazedonien",
"tippligaID": 805,
"apiFootballID": 1105
},
{
"teamname": "Wuppertaler SV",
"tippligaID": 62,
"apiFootballID": 9375
},
{
"teamname": "VfL Oldenburg",
"tippligaID": 630,
"apiFootballID": 12888
},
{
"teamname": "TuS RW Koblenz",
"tippligaID": 32,
"apiFootballID": 1657
},
{
"teamname": "Greifswalder FC",
"tippligaID": 631,
"apiFootballID": 16118
},
{
"teamname": "Bayreuth",
"tippligaID": 137,
"apiFootballID": 9325
},
{
"teamname": "Lokomotive Leipzig",
"tippligaID": 632,
"apiFootballID": 9355
},
{
"teamname": "Weiche Flensburg",
"tippligaID": 121,
"apiFootballID": 1649
},
{
"teamname": "Bremer Sv",
"tippligaID": 602,
"apiFootballID": 1630
},
{
"teamname": "FC Saarbrucken",
"tippligaID": 44,
"apiFootballID": 1639
},
{
"teamname": "Verl",
"tippligaID": 52,
"apiFootballID": 4265
}
]

View File

@@ -9,10 +9,12 @@ import static org.junit.Assert.assertEquals;
public class TLWMatchdaysCreatorTest {
int season = 2022;
@Test
public void getMatchdaysTippligaTest() {
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 1, "Tippliga");
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 1, "Tippliga");
ArrayList<TLWMatchday> matchdays = matchdaysCreator.getMatchdays();
assertEquals((Integer) 1, matchdays.get(0).getMatchday());
@@ -20,7 +22,7 @@ public class TLWMatchdaysCreatorTest {
@Test
public void getMatchdaysWTLPokalTest() {
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 1, "WTL-Pokal");
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 1, "WTL-Pokal");
ArrayList<TLWMatchday> matchdays = matchdaysCreator.getMatchdays();
assertEquals((Integer) 1, matchdays.get(0).getMatchday());
@@ -29,49 +31,49 @@ public class TLWMatchdaysCreatorTest {
@Test
public void getMatchdaysTippliga1SqlTest() {
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 1, "Tippliga");
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 1, "Tippliga");
String sql = matchdaysCreator.getMatchdaysSQL();
// System.out.println(sql);
System.out.println(sql);
}
@Test
public void getMatchdaysTippliga2SqlTest() {
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 2, "Tippliga");
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 2, "Tippliga");
String sql = matchdaysCreator.getMatchdaysSQL();
// System.out.println(sql);
System.out.println(sql);
}
@Test
public void getMatchdaysTippliga51SqlTest() {
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 51, "Tippliga");
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 51, "Tippliga");
String sql = matchdaysCreator.getMatchdaysSQL();
// System.out.println(sql);
System.out.println(sql);
}
@Test
public void getMatchdaysTippliga52SqlTest() {
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 52, "Tippliga");
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 52, "Tippliga");
String sql = matchdaysCreator.getMatchdaysSQL();
// System.out.println(sql);
System.out.println(sql);
}
@Test
public void getMatchdaysWTLPokal48SqlTest() {
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 48, "WTL-Pokal");
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 48, "WTL-Pokal");
String sql = matchdaysCreator.getMatchdaysSQL();
// System.out.println(sql);
System.out.println(sql);
}
@Test
public void getMatchdaysWTLPokal98SqlTest() {
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 98, "WTL-Pokal");
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 98, "WTL-Pokal");
String sql = matchdaysCreator.getMatchdaysSQL();
// System.out.println(sql);
System.out.println(sql);
}
@Test

View File

@@ -8,6 +8,8 @@ import static org.junit.Assert.assertEquals;
public class TLWMatchesCreatorFootballTest {
int season = 2022;
@Test
public void getMatchesTest() {
TLWMatchesCreatorFootball creator = new TLWMatchesCreatorFootball(2021, 1, "WTL-Pokal");
@@ -19,17 +21,24 @@ public class TLWMatchesCreatorFootballTest {
}
@Test
public void getMatchesTippligaSqlTest() {
TLWMatchesCreatorFootball creator = new TLWMatchesCreatorFootball(2021, 2, "Tippliga");
public void getMatchesTippliga1SqlTest() {
TLWMatchesCreatorFootball creator = new TLWMatchesCreatorFootball(season, 1, "Tippliga");
String sql = creator.getSQLInsertString();
// System.out.println(sql);
System.out.println(sql);
}
@Test
public void getMatchesTippliga2SqlTest() {
TLWMatchesCreatorFootball creator = new TLWMatchesCreatorFootball(season, 2, "Tippliga");
String sql = creator.getSQLInsertString();
System.out.println(sql);
}
@Test
public void getMatchesWTLPokalSqlTest() {
TLWMatchesCreatorFootball creator = new TLWMatchesCreatorFootball(2021, 48, "WTL-Pokal");
TLWMatchesCreatorFootball creator = new TLWMatchesCreatorFootball(season, 48, "WTL-Pokal");
String sql = creator.getSQLInsertString();
// System.out.println(sql);
System.out.println(sql);
}
@Test

View File

@@ -2,17 +2,15 @@ package de.jeyp91.tippliga;
import org.junit.Test;
import java.text.ParseException;
public class TLWMatchesCreatorTipperPokalTest {
@Test
public void getMatchesWTLPokalTest() throws ParseException {
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 48, "WTL-Pokal");
public void getMatchesWTLPokalTest() {
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2022, 48, "WTL-Pokal");
TLWMatchesCreatorTipperPokal creator = new TLWMatchesCreatorTipperPokal(2021, 98, "WTL-Pokal Tipper", matchdaysCreator.getMatchdays());
TLWMatchesCreatorTipperPokal creator = new TLWMatchesCreatorTipperPokal(2022, 98, "WTL-Pokal Tipper", matchdaysCreator.getMatchdays());
String sql = creator.getSQLInsertString();
// System.out.println(sql);
System.out.println(sql);
}
}

View File

@@ -8,13 +8,25 @@ import static org.junit.Assert.assertEquals;
public class TLWMatchesCreatorTipperTest {
@Test
public void getMatchesTippligaTest() throws ParseException {
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 2, "Tippliga");
int season = 2022;
TLWMatchesCreatorTipperLeague creator = new TLWMatchesCreatorTipperLeague(2021, 52, "2. Tippliga Tipper", matchdaysCreator.getMatchdays());
@Test
public void getMatchesTippliga1Test() {
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 1, "Tippliga");
TLWMatchesCreatorTipperLeague creator = new TLWMatchesCreatorTipperLeague(season, 51, "1. Tippliga Tipper", matchdaysCreator.getMatchdays());
String sql = creator.getSQLInsertString();
// System.out.println(sql);
System.out.println(sql);
}
@Test
public void getMatchesTippliga2Test() {
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 2, "Tippliga");
TLWMatchesCreatorTipperLeague creator = new TLWMatchesCreatorTipperLeague(season, 52, "2. Tippliga Tipper", matchdaysCreator.getMatchdays());
String sql = creator.getSQLInsertString();
System.out.println(sql);
}
}

View File

@@ -8,14 +8,37 @@ import java.util.ArrayList;
import static org.junit.Assert.assertEquals;
public class TLWTeamsCreatorTest {
int season = 2022;
@Test
public void getTeamsTippligaFootball1Test() {
TLWMatchesCreatorFootball matchesCreator = new TLWMatchesCreatorFootball(2021, 1, "Tippliga");
TLWMatchesCreatorFootball matchesCreator = new TLWMatchesCreatorFootball(season, 1, "Tippliga");
ArrayList<TLWMatch> matches = matchesCreator.getMatches();
TLWTeamsCreator teamCreator = new TLWTeamsCreator(2021, 1, matches);
TLWTeamsCreator teamCreator = new TLWTeamsCreator(season, 1, matches);
String sql = teamCreator.getSql();
// System.out.println(sql);
System.out.println(sql);
}
@Test
public void getTeamsTippligaFootball2Test() {
TLWMatchesCreatorFootball matchesCreator = new TLWMatchesCreatorFootball(season, 2, "Tippliga");
ArrayList<TLWMatch> matches = matchesCreator.getMatches();
TLWTeamsCreator teamCreator = new TLWTeamsCreator(season, 2, matches);
String sql = teamCreator.getSql();
System.out.println(sql);
}
@Test
public void getTeamsWTLPokalTest() {
TLWMatchesCreatorFootball matchesCreator = new TLWMatchesCreatorFootball(season, 48, "WTL-Pokal");
ArrayList<TLWMatch> matches = matchesCreator.getMatches();
TLWTeamsCreator teamCreator = new TLWTeamsCreator(season, 48, matches);
String sql = teamCreator.getSql();
System.out.println(sql);
}
@Test
@@ -30,40 +53,40 @@ public class TLWTeamsCreatorTest {
@Test
public void getTeamsTipper1TLTest() throws ParseException {
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 1, "Tippliga");
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 1, "Tippliga");
TLWMatchesCreatorTipperLeague creator = new TLWMatchesCreatorTipperLeague(2021, 51, "1. Tippliga Tipper", matchdaysCreator.getMatchdays());
TLWMatchesCreatorTipperLeague creator = new TLWMatchesCreatorTipperLeague(season, 51, "1. Tippliga Tipper", matchdaysCreator.getMatchdays());
ArrayList<TLWMatch> matches = creator.getMatches();
TLWTeamsCreator teamCreator = new TLWTeamsCreator(2021, 51, matches);
TLWTeamsCreator teamCreator = new TLWTeamsCreator(season, 51, matches);
String sql = teamCreator.getSql();
// System.out.println(sql);
System.out.println(sql);
}
@Test
public void getTeamsTipper2TLTest() throws ParseException {
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 2, "Tippliga");
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 2, "Tippliga");
TLWMatchesCreatorTipperLeague creator = new TLWMatchesCreatorTipperLeague(2021, 52, "2. Tippliga Tipper", matchdaysCreator.getMatchdays());
TLWMatchesCreatorTipperLeague creator = new TLWMatchesCreatorTipperLeague(season, 52, "2. Tippliga Tipper", matchdaysCreator.getMatchdays());
ArrayList<TLWMatch> matches = creator.getMatches();
TLWTeamsCreator teamCreator = new TLWTeamsCreator(2021, 52, matches);
TLWTeamsCreator teamCreator = new TLWTeamsCreator(season, 52, matches);
String sql = teamCreator.getSql();
// System.out.println(sql);
System.out.println(sql);
}
@Test
public void getTeamsTipperWTLTest() throws ParseException {
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 48, "WTL-Pokal");
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 48, "WTL-Pokal");
TLWMatchesCreatorTipperPokal creator = new TLWMatchesCreatorTipperPokal(2021, 98, "WTL-Pokal Tipper", matchdaysCreator.getMatchdays());
TLWMatchesCreatorTipperPokal creator = new TLWMatchesCreatorTipperPokal(season, 98, "WTL-Pokal Tipper", matchdaysCreator.getMatchdays());
ArrayList<TLWMatch> matches = creator.getMatches();
TLWTeamsCreator teamCreator = new TLWTeamsCreator(2021, 98, matches);
TLWTeamsCreator teamCreator = new TLWTeamsCreator(season, 98, matches);
String sql = teamCreator.getSql();
// System.out.println(sql);
System.out.println(sql);
}
}

View File

@@ -1,21 +1,18 @@
package de.jeyp91.tippligaforum;
import de.jeyp91.tippligaforum.MatchesListForumUpdater;
import org.junit.Test;
import java.io.UnsupportedEncodingException;
public class MatchesListForumUpdaterTest {
@Test
public void updateAllLeaguesTest() {
MatchesListForumUpdater updater = new MatchesListForumUpdater();
// updater.updateAllLeagues();
MatchesListForumUpdater updater = new MatchesListForumUpdater(2022);
// updater.updateAllLeagues(2022);
}
@Test
public void updateLeagueTest() {
MatchesListForumUpdater updater = new MatchesListForumUpdater();
updater.updateLeague(2743);
MatchesListForumUpdater updater = new MatchesListForumUpdater(2022);
updater.updateLeague(2022, 3509);
}
}