Improve logic for adding missing matches with placeholder and formula
This commit is contained in:
@@ -168,13 +168,23 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
||||
}
|
||||
|
||||
for (APIFootballMatch missingMatch : missingMatches) {
|
||||
Integer missingTeamIdHome = TeamIDMatcher.getTippligaIdFromApiFootballId(missingMatch, TeamIDMatcher.HOME);
|
||||
Integer missingTeamIdGuest = TeamIDMatcher.getTippligaIdFromApiFootballId(missingMatch, TeamIDMatcher.GUEST);
|
||||
boolean done = false;
|
||||
// update placeholder match based on matching match datetime
|
||||
for (TLWMatch tlwMatch : tlwMatches) {
|
||||
if ( tlwMatch.getTeamIdHome() == 0 && tlwMatch.getTeamIdGuest() == 0
|
||||
&& Objects.equals(tlwMatch.getMatchDateTime(), missingMatch.getMatchDateTime().replace("T", " ").substring(0, 19))
|
||||
&& !Objects.equals(tlwMatch.getFormulaHome(), "")
|
||||
&& !Objects.equals(tlwMatch.getFormulaGuest(), "")) {
|
||||
Boolean homeMatches = tlwMatch.getTeamIdHome() == 0 || tlwMatch.getTeamIdHome().equals(missingTeamIdHome);
|
||||
Boolean guestMatches =tlwMatch.getTeamIdGuest() == 0 || tlwMatch.getTeamIdGuest().equals(missingTeamIdGuest);
|
||||
Boolean timeMatches = Objects.equals(tlwMatch.getMatchDateTime(), missingMatch.getMatchDateTime().replace("T", " ").substring(0, 19));
|
||||
Boolean formulaHomeMatches = !Objects.equals(tlwMatch.getFormulaHome(), "");
|
||||
Boolean formulaGuestMatches = !Objects.equals(tlwMatch.getFormulaGuest(), "");
|
||||
if (
|
||||
homeMatches
|
||||
&& guestMatches
|
||||
&& timeMatches
|
||||
&& formulaHomeMatches
|
||||
&& formulaGuestMatches
|
||||
) {
|
||||
tlwMatch.updateMatch(missingMatch);
|
||||
done = true;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user