mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-10 14:20:55 +00:00
Implementation of countdown stage for races
This commit is contained in:
1 parent
27b2af2a95
commit
6765e295cc
3 files changed
+55
-8
No files matched your search
+10
-6
@@ -43,11 +43,11 @@ public class GetEventOverviewStageAction implements Action<ResultWithTTL<EventOv
|
||||
}
|
||||
|
||||
// TODO get correct message
|
||||
return new ResultWithTTL<>(ttl, new EventOverviewStageDTO(null, getStageContent(event, state, now)));
|
||||
return new ResultWithTTL<>(ttl, new EventOverviewStageDTO(null, getStageContent(context, event, state, now)));
|
||||
}
|
||||
|
||||
@GwtIncompatible
|
||||
public EventOverviewStageContentDTO getStageContent(Event event, EventState state, MillisecondsTimePoint now) {
|
||||
public EventOverviewStageContentDTO getStageContent(DispatchContext context, Event event, EventState state, MillisecondsTimePoint now) {
|
||||
String stageImageUrl = HomeServiceUtil.getStageImageURLAsString(event);
|
||||
// if(state == EventState.RUNNING && TODO live video) {
|
||||
// return new EventOverviewVideoStageDTO(Type.LIVESTREAM);
|
||||
@@ -58,11 +58,15 @@ public class GetEventOverviewStageAction implements Action<ResultWithTTL<EventOv
|
||||
// }
|
||||
|
||||
if(state == EventState.RUNNING) {
|
||||
// TODO next race countdown if available
|
||||
// TODO Proper Implementation (Type race)
|
||||
// return new EventOverviewRaceTickerStageDTO(new RegattaNameAndRaceName(
|
||||
// "Regatta XY", "Race 1"), "Race 1 - Gold Fleet", new Date(new Date().getTime() + 5000), stageImageUrl);
|
||||
NextRaceFinder nextRaceFinder = new NextRaceFinder();
|
||||
RacesActionUtil.forRacesOfEvent(context, eventId, nextRaceFinder);
|
||||
|
||||
RaceContext nextRace = nextRaceFinder .getNextRace();
|
||||
if(nextRace != null) {
|
||||
return new EventOverviewRaceTickerStageDTO(nextRace.getRaceIdentifier(), nextRace.getStageText(), nextRaceFinder.getNextStartTime().asDate(), stageImageUrl);
|
||||
}
|
||||
|
||||
// TODO This is not a good idea due to Axel and Frank as regatta start times aren't correctly set.
|
||||
Regatta nextRegatta = null;
|
||||
for (LeaderboardGroup lg : event.getLeaderboardGroups()) {
|
||||
for (Leaderboard lb : lg.getLeaderboards()) {
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.sap.sailing.gwt.ui.shared.dispatch.event;
|
||||
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.event.RacesActionUtil.RaceCallback;
|
||||
import com.sap.sailing.gwt.ui.shared.race.RaceMetadataDTO.RaceTrackingState;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
|
||||
public class NextRaceFinder implements RaceCallback {
|
||||
|
||||
private final TimePoint now = MillisecondsTimePoint.now();
|
||||
private TimePoint nextStartTime;
|
||||
private RaceContext nextRace;
|
||||
|
||||
@Override
|
||||
public void doForRace(RaceContext context) {
|
||||
TimePoint startTime = context.getStartTime();
|
||||
if(context.getRaceTrackingState() != RaceTrackingState.TRACKED_VALID_DATA || startTime == null || now.after(startTime)) {
|
||||
return;
|
||||
}
|
||||
if(nextRace == null || startTime.before(nextStartTime)) {
|
||||
nextRace = context;
|
||||
nextStartTime = startTime;
|
||||
}
|
||||
}
|
||||
|
||||
public RaceContext getNextRace() {
|
||||
return nextRace;
|
||||
}
|
||||
|
||||
public TimePoint getNextStartTime() {
|
||||
return nextStartTime;
|
||||
}
|
||||
}
|
||||
+12
-2
@@ -20,6 +20,7 @@ import com.sap.sailing.domain.base.RaceDefinition;
|
||||
import com.sap.sailing.domain.base.Regatta;
|
||||
import com.sap.sailing.domain.common.LeaderboardNameConstants;
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
|
||||
import com.sap.sailing.domain.common.TimingConstants;
|
||||
import com.sap.sailing.domain.common.Wind;
|
||||
import com.sap.sailing.domain.common.WindSourceType;
|
||||
@@ -209,7 +210,7 @@ public class RaceContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
private TimePoint getStartTime() {
|
||||
public TimePoint getStartTime() {
|
||||
TimePoint startTime = null;
|
||||
if (trackedRace != null) {
|
||||
startTime = trackedRace.getStartOfRace();
|
||||
@@ -285,7 +286,7 @@ public class RaceContext {
|
||||
return result;
|
||||
}
|
||||
|
||||
private RaceTrackingState getRaceTrackingState() {
|
||||
public RaceTrackingState getRaceTrackingState() {
|
||||
RaceTrackingState trackingState = RaceTrackingState.NOT_TRACKED;
|
||||
if(trackedRace != null) {
|
||||
trackingState = RaceTrackingState.TRACKED_NO_VALID_DATA;
|
||||
@@ -331,4 +332,13 @@ public class RaceContext {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getStageText() {
|
||||
// TODO fleet
|
||||
return getRegattaDisplayName() + " - " + raceColumn.getName();
|
||||
}
|
||||
|
||||
public RegattaAndRaceIdentifier getRaceIdentifier() {
|
||||
return trackedRace.getRaceIdentifier();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user