Fix MatchesListForumUpdater

This commit is contained in:
2025-01-27 22:14:06 +01:00
parent 258ff19064
commit 38fba7b906
4 changed files with 45 additions and 19 deletions

10
.vscode/launch.json vendored
View File

@@ -34,7 +34,15 @@
"request": "launch", "request": "launch",
"mainClass": "de.jeyp91.App", "mainClass": "de.jeyp91.App",
"envFile": "${workspaceFolder}/.env", "envFile": "${workspaceFolder}/.env",
"args": " --mode MatchesResultsUpdater --season 2025 --league 2 --configFile Tippliga" "args": " --mode MatchesResultsUpdater --season 2025 --league 1 --configFile Tippliga"
},
{
"type": "java",
"name": "MatchesListGistUpdater",
"request": "launch",
"mainClass": "de.jeyp91.App",
"envFile": "${workspaceFolder}/.env",
"args": " --mode MatchesListGistUpdater --season 2025 --league 1 --configFile Tippliga"
} }
] ]
} }

View File

@@ -1,11 +1,16 @@
package de.jeyp91.tippligaforum; package de.jeyp91.tippligaforum;
import com.google.gson.*;
import de.jeyp91.S3Provider;
import de.jeyp91.apifootball.APIFootballMatch;
import org.json.simple.JSONArray; import org.json.simple.JSONArray;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import de.jeyp91.S3Provider;
import de.jeyp91.apifootball.APIFootballMatch;
public class MatchesListCreator { public class MatchesListCreator {
private final JSONObject mainObject = new JSONObject(); private final JSONObject mainObject = new JSONObject();
@@ -19,8 +24,7 @@ public class MatchesListCreator {
this.league = league; this.league = league;
S3Provider prov = new S3Provider(); S3Provider prov = new S3Provider();
JSONObject leagueConfig = prov.getFixturesJSONFromS3(season, league); JSONObject leagueConfig = prov.getFixturesJSONFromS3(season, league);
JSONObject api = (JSONObject) leagueConfig.get("api"); JSONArray matchesAPIFootball = (JSONArray) leagueConfig.get("response");
JSONArray matchesAPIFootball = (JSONArray) api.get("fixtures");
JSONObject firstMatchAPIFootball = (JSONObject) matchesAPIFootball.get(0); JSONObject firstMatchAPIFootball = (JSONObject) matchesAPIFootball.get(0);
JSONObject leagueObject = (JSONObject) firstMatchAPIFootball.get("league"); JSONObject leagueObject = (JSONObject) firstMatchAPIFootball.get("league");
@@ -44,16 +48,20 @@ public class MatchesListCreator {
JSONObject matchAPIFootball = (JSONObject) matchAPIFootballObject; JSONObject matchAPIFootball = (JSONObject) matchAPIFootballObject;
JSONObject match = new JSONObject(); JSONObject match = new JSONObject();
Long leagueId = (Long) matchAPIFootball.get("league_id"); JSONObject leagueObject = (JSONObject) matchAPIFootball.get("league");
String matchdayString = matchAPIFootball.get("round").toString(); Long leagueId = (Long) leagueObject.get("id");
String matchdayString = leagueObject.get("round").toString();
int matchday = APIFootballMatch.getMatchdayFromRoundString(this.season, matchdayString, leagueId.intValue()); int matchday = APIFootballMatch.getMatchdayFromRoundString(this.season, matchdayString, leagueId.intValue());
String matchtime = matchAPIFootball.get("event_date").toString().replace("T", " ").substring(0, 16);
Long fixtureId = (Long) matchAPIFootball.get("fixture_id");
JSONObject teamHome = (JSONObject) matchAPIFootball.get("homeTeam"); JSONObject fixtureObject = (JSONObject) matchAPIFootball.get("fixture");
String teamNameHome = teamHome.get("team_name").toString(); String matchtime = fixtureObject.get("date").toString().replace("T", " ").substring(0, 16);
JSONObject teamGuest = (JSONObject) matchAPIFootball.get("awayTeam"); Long fixtureId = (Long) fixtureObject.get("id");
String teamNameGuest = teamGuest.get("team_name").toString();
JSONObject teamsObject = (JSONObject) matchAPIFootball.get("teams");
JSONObject teamHome = (JSONObject) teamsObject.get("home");
String teamNameHome = teamHome.get("name").toString();
JSONObject teamGuest = (JSONObject) teamsObject.get("away");
String teamNameGuest = teamGuest.get("name").toString();
match.put("match", teamNameHome + " - " + teamNameGuest); match.put("match", teamNameHome + " - " + teamNameGuest);
match.put("matchday", matchday); match.put("matchday", matchday);

View File

@@ -1,14 +1,14 @@
package de.jeyp91.tippligaforum; package de.jeyp91.tippligaforum;
import de.jeyp91.App;
import de.jeyp91.apifootball.APIFootballUpdater;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.HashSet; import java.util.HashSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.jeyp91.apifootball.APIFootballUpdater;
public class MatchesListForumUpdater { public class MatchesListForumUpdater {
private HashSet<Integer> leagues; private HashSet<Integer> leagues;
private static final Logger logger = LoggerFactory.getLogger(MatchesListForumUpdater.class); private static final Logger logger = LoggerFactory.getLogger(MatchesListForumUpdater.class);

View File

@@ -93,5 +93,15 @@
"country": "World", "country": "World",
"name": "UEFA Super Cup", "name": "UEFA Super Cup",
"league_id": 531 "league_id": 531
},
{
"country": "World",
"name": "World Cup",
"league_id": 1
},
{
"country": "World",
"name": "Euro Championship",
"league_id": 4
} }
] ]