Only update result if api football match is finished

This commit is contained in:
Julian Arndt
2023-08-20 11:55:53 +02:00
parent 29f00f39aa
commit b411f5d57f
4 changed files with 48 additions and 37 deletions

View File

@@ -6,11 +6,11 @@ import org.json.simple.JSONObject;
public class APIFootballMatch extends BaseMatch {
private final int matchId;
private final int leagueId;
private final String teamNameHome;
private final String teamNameGuest;
private final String round;
private int matchId;
private int leagueId;
private String teamNameHome;
private String teamNameGuest;
private String round;
private Boolean showTable = null;
public APIFootballMatch(JSONObject json, int season) throws Exception {
@@ -30,6 +30,7 @@ public class APIFootballMatch extends BaseMatch {
throw new Exception("Did not find matchday for league '" + this.leagueId + "': '" + json.get("round").toString() + "'");
}
this.matchDatetime = (String) json.get("event_date");
this.status = parseStatus(json.get("statusShort").toString());
this.parseResult(json);
}
@@ -76,6 +77,17 @@ public class APIFootballMatch extends BaseMatch {
return this.showTable;
}
private int parseStatus(String statusShort) {
switch (statusShort) {
case "TBD":
case "NS": return 0;
case "FT":
case "AET":
case "PEN": return 3;
default: return 1;
}
}
private void parseResult(JSONObject json) {
Object resultFulltime = ((JSONObject) json.get("score")).get("fulltime");
if(resultFulltime != null) {