Only update result if api football match is finished
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user