mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-08 21:30:57 +00:00
Extended implementation to gather regattas/live races for mobile
This commit is contained in:
1 parent
c1cd61b419
commit
66c7c860cd
1 file changed
+23
-1
+23
-1
@@ -7,6 +7,9 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.google.gwt.core.shared.GwtIncompatible;
|
||||
import com.sap.sailing.domain.base.Event;
|
||||
import com.sap.sailing.domain.leaderboard.Leaderboard;
|
||||
import com.sap.sailing.domain.leaderboard.LeaderboardGroup;
|
||||
import com.sap.sailing.gwt.server.HomeServiceUtil;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.Action;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.DispatchContext;
|
||||
@@ -44,21 +47,40 @@ public class GetRegattasAndLiveRacesForEventAction implements Action<ResultWithT
|
||||
}
|
||||
});
|
||||
|
||||
ensureRegattas(regattasWithRaces, context);
|
||||
|
||||
RegattasAndLiveRacesDTO result = new RegattasAndLiveRacesDTO(regattasWithRaces);
|
||||
long duration = System.currentTimeMillis() - start;
|
||||
logger.log(Level.INFO, "Calculating live races for event "+ eventId + " took: "+ duration + "ms");
|
||||
return new ResultWithTTL<RegattasAndLiveRacesDTO>(1000 * 60 * 2, result);
|
||||
}
|
||||
|
||||
private void ensureRegattas(ArrayList<Pair<RegattaMetadataDTO, TreeSet<LiveRaceDTO>>> regattasWithRaces, DispatchContext context) {
|
||||
Event event = context.getRacingEventService().getEvent(eventId);
|
||||
for (LeaderboardGroup lg : event.getLeaderboardGroups()) {
|
||||
for (Leaderboard lb : lg.getLeaderboards()) {
|
||||
ensureRegatta(regattasWithRaces, lb.getName(), lg, lb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected Pair<RegattaMetadataDTO, TreeSet<LiveRaceDTO>> ensureRegatta(ArrayList<Pair<RegattaMetadataDTO, TreeSet<LiveRaceDTO>>> regattasWithRaces,
|
||||
RaceContext context) {
|
||||
String regattaName = context.getRegattaName();
|
||||
LeaderboardGroup leaderboardGroup = context.getLeaderboardGroup();
|
||||
Leaderboard leaderboard = context.getLeaderboard();
|
||||
return ensureRegatta(regattasWithRaces, regattaName, leaderboardGroup, leaderboard);
|
||||
}
|
||||
|
||||
private Pair<RegattaMetadataDTO, TreeSet<LiveRaceDTO>> ensureRegatta(
|
||||
ArrayList<Pair<RegattaMetadataDTO, TreeSet<LiveRaceDTO>>> regattasWithRaces, String regattaName,
|
||||
LeaderboardGroup leaderboardGroup, Leaderboard leaderboard) {
|
||||
for(Pair<RegattaMetadataDTO, TreeSet<LiveRaceDTO>> regatta : regattasWithRaces) {
|
||||
if(regatta.getA().getId().equals(regattaName)) {
|
||||
return regatta;
|
||||
}
|
||||
}
|
||||
Pair<RegattaMetadataDTO, TreeSet<LiveRaceDTO>> newEntry = new Pair<RegattaMetadataDTO, TreeSet<LiveRaceDTO>>(HomeServiceUtil.toRegattaMetadataDTO(context.getLeaderboardGroup(), context.getLeaderboard()), new TreeSet<LiveRaceDTO>());
|
||||
Pair<RegattaMetadataDTO, TreeSet<LiveRaceDTO>> newEntry = new Pair<RegattaMetadataDTO, TreeSet<LiveRaceDTO>>(HomeServiceUtil.toRegattaMetadataDTO(leaderboardGroup, leaderboard), new TreeSet<LiveRaceDTO>());
|
||||
regattasWithRaces.add(newEntry);
|
||||
return newEntry;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user