mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-27 06:17:27 +00:00
Optimized scheduling of refreshes
This commit is contained in:
1 parent
83dd8d53ba
commit
2914a81b3d
4 files changed
+21
-5
No files matched your search
+13
@@ -59,6 +59,19 @@ public final class EventActionUtil {
|
||||
throw new DispatchException("The leaderboard is not part of the given event.");
|
||||
}
|
||||
|
||||
public static long getEventStateDependentTTL(DispatchContext context, UUID eventId, long liveTTL) {
|
||||
Event event = context.getRacingEventService().getEvent(eventId);
|
||||
return getEventStateDependentTTL(event, liveTTL);
|
||||
}
|
||||
|
||||
private static long getEventStateDependentTTL(Event event, long liveTTL) {
|
||||
EventState eventState = HomeServiceUtil.calculateEventState(event);
|
||||
if(eventState == EventState.RUNNING) {
|
||||
return liveTTL;
|
||||
}
|
||||
return calculateTtlForNonLiveEvent(event, eventState);
|
||||
}
|
||||
|
||||
public static <T extends DTO> ResultWithTTL<T> withLiveRaceOrDefaultSchedule(DispatchContext context, UUID eventId, CalculationWithEvent<T> callback) {
|
||||
Event event = context.getRacingEventService().getEvent(eventId);
|
||||
EventState eventState = HomeServiceUtil.calculateEventState(event);
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ public class GetRaceListViewAction implements Action<ResultWithTTL<RaceListViewD
|
||||
long start = System.currentTimeMillis();
|
||||
RaceListDataCalculator raceListDataCalculator = new RaceListDataCalculator();
|
||||
EventActionUtil.forRacesOfRegatta(context, eventId, regattaId, raceListDataCalculator);
|
||||
ResultWithTTL<RaceListViewDTO> result = raceListDataCalculator.getResult();
|
||||
ResultWithTTL<RaceListViewDTO> result = raceListDataCalculator.getResult(context, eventId);
|
||||
|
||||
long duration = System.currentTimeMillis() - start;
|
||||
logger.log(Level.INFO, "Calculating race list for event "+ eventId + " took: "+ duration + "ms");
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@ public class GetRegattaListViewAction implements Action<ResultWithTTL<SortedSetR
|
||||
public void doForLeaderboard(LeaderboardContext leaderboardContext) {
|
||||
result.add(leaderboardContext.getRegattaWithProgress(context));
|
||||
}
|
||||
});
|
||||
return new ResultWithTTL<>(5 * 1000, new SortedSetResult<>(result));
|
||||
});
|
||||
return new ResultWithTTL<>(EventActionUtil.getEventStateDependentTTL(context, eventId, 3 * 60 * 1000), new SortedSetResult<>(result));
|
||||
}
|
||||
}
|
||||
+5
-2
@@ -1,6 +1,9 @@
|
||||
package com.sap.sailing.gwt.ui.shared.dispatch.event;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.gwt.core.shared.GwtIncompatible;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.DispatchContext;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.ResultWithTTL;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.event.EventActionUtil.RaceCallback;
|
||||
|
||||
@@ -17,9 +20,9 @@ public class RaceListDataCalculator implements RaceCallback {
|
||||
result.add(context.getFinishedRaceOrNull());
|
||||
}
|
||||
|
||||
public ResultWithTTL<RaceListViewDTO> getResult() {
|
||||
public ResultWithTTL<RaceListViewDTO> getResult(DispatchContext context, UUID eventId) {
|
||||
result.setProgress(progressCalculator.getResult());
|
||||
return new ResultWithTTL<>(5000, result);
|
||||
return new ResultWithTTL<>(EventActionUtil.getEventStateDependentTTL(context, eventId, 3 * 60 * 1000), result);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user