mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-04 19:33:52 +00:00
avoid creation of a TrackedRace which may unnecessarily block, only to show the race in listevents
This commit is contained in:
1 parent
809b2ae1aa
commit
2d57f8fbd7
1 file changed
+17
-14
@@ -375,21 +375,24 @@ public class ModeratorApp extends Servlet {
|
||||
jsonEvent.put("competitors", jsonCompetitors);
|
||||
JSONArray jsonRaces = new JSONArray();
|
||||
for (RaceDefinition race : event.getAllRaces()) {
|
||||
JSONObject jsonRace = new JSONObject();
|
||||
jsonRace.put("name", race.getName());
|
||||
jsonRace.put("boatclass", race.getBoatClass()==null?"":race.getBoatClass().getName());
|
||||
TrackedRace trackedRace = getService().getDomainFactory().getOrCreateTrackedEvent(event).getTrackedRace(race);
|
||||
TimePoint start = trackedRace.getStart();
|
||||
jsonRace.put("start", start==null?Long.MAX_VALUE:start.asMillis());
|
||||
JSONArray jsonLegs = new JSONArray();
|
||||
for (Leg leg : race.getCourse().getLegs()) {
|
||||
JSONObject jsonLeg = new JSONObject();
|
||||
jsonLeg.put("start", leg.getFrom().getName());
|
||||
jsonLeg.put("end", leg.getTo().getName());
|
||||
jsonLegs.add(jsonLeg);
|
||||
// don't wait for the arrival of a tracked race; just ignore it if it's not currently being tracked
|
||||
TrackedRace trackedRace = getService().getDomainFactory().getOrCreateTrackedEvent(event).getExistingTrackedRace(race);
|
||||
if (trackedRace != null) {
|
||||
JSONObject jsonRace = new JSONObject();
|
||||
jsonRace.put("name", race.getName());
|
||||
jsonRace.put("boatclass", race.getBoatClass() == null ? "" : race.getBoatClass().getName());
|
||||
TimePoint start = trackedRace.getStart();
|
||||
jsonRace.put("start", start == null ? Long.MAX_VALUE : start.asMillis());
|
||||
JSONArray jsonLegs = new JSONArray();
|
||||
for (Leg leg : race.getCourse().getLegs()) {
|
||||
JSONObject jsonLeg = new JSONObject();
|
||||
jsonLeg.put("start", leg.getFrom().getName());
|
||||
jsonLeg.put("end", leg.getTo().getName());
|
||||
jsonLegs.add(jsonLeg);
|
||||
}
|
||||
jsonRace.put("legs", jsonLegs);
|
||||
jsonRaces.add(jsonRace);
|
||||
}
|
||||
jsonRace.put("legs", jsonLegs);
|
||||
jsonRaces.add(jsonRace);
|
||||
}
|
||||
jsonEvent.put("races", jsonRaces);
|
||||
eventList.add(jsonEvent);
|
||||
|
||||
Reference in new issue
Block a user