mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-30 17:36:40 +00:00
First implementation to load chart data just until now-delay
This commit is contained in:
1 parent
ab0c4d1ccd
commit
b21b84348d
5 files changed
+18
-17
No files matched your search
+6
-3
@@ -260,7 +260,8 @@ public class WindChart implements Component<WindChartSettings>, RaceSelectionCha
|
||||
selectedRaceIdentifier = selectedRaces.iterator().next();
|
||||
timeOfEarliestRequestInMillis = null;
|
||||
timeOfLatestRequestInMillis = null;
|
||||
loadData(selectedRaceIdentifier, /* from */ null, /* to */ null, /* append */ false);
|
||||
loadData(selectedRaceIdentifier, /* from */null, /* to */
|
||||
new Date(System.currentTimeMillis() - timer.getLivePlayDelayInMillis()), /* append */false);
|
||||
} else {
|
||||
clearChart();
|
||||
}
|
||||
@@ -278,13 +279,15 @@ public class WindChart implements Component<WindChartSettings>, RaceSelectionCha
|
||||
if (timeOfEarliestRequestInMillis == null || timeOfEarliestRequestInMillis > date.getTime()) {
|
||||
loadData(selectedRaceIdentifier, null, date, /* append */ true);
|
||||
} else if (timeOfLatestRequestInMillis < date.getTime()) {
|
||||
loadData(selectedRaceIdentifier, new Date(timeOfLatestRequestInMillis), /* to */ null, /* append */ true);
|
||||
loadData(selectedRaceIdentifier, new Date(timeOfLatestRequestInMillis), /* to */
|
||||
new Date(System.currentTimeMillis() - timer.getLivePlayDelayInMillis()), /* append */true);
|
||||
}
|
||||
// otherwise the cache spans across date and so we don't need to load anything
|
||||
} else {
|
||||
// assuming play mode is replay / non-live
|
||||
if (timeOfLatestRequestInMillis == null) {
|
||||
loadData(selectedRaceIdentifier, /* from */ null, /* to */ null, /* append */ false); // replace old series
|
||||
loadData(selectedRaceIdentifier, /* from */null, /* to */
|
||||
new Date(System.currentTimeMillis() - timer.getLivePlayDelayInMillis()), /* append */false); // replace old series
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-6
@@ -139,11 +139,6 @@ public interface SailingService extends RemoteService {
|
||||
|
||||
String[] getCountryCodes();
|
||||
|
||||
// CompetitorInRaceDTO getCompetitorRaceData(RaceIdentifier race,
|
||||
// CompetitorsAndTimePointsDTO competitorsAndTimePointsDTO, DetailType dataType) throws NoWindException;
|
||||
|
||||
// CompetitorsAndTimePointsDTO getCompetitorsAndTimePoints(RaceIdentifier race, long stepSize);
|
||||
|
||||
Map<CompetitorDTO, List<GPSFixDTO>> getDouglasPoints(RaceIdentifier raceIdentifier,
|
||||
Map<CompetitorDTO, Date> from, Map<CompetitorDTO, Date> to, double meters) throws NoWindException;
|
||||
|
||||
@@ -164,6 +159,7 @@ public interface SailingService extends RemoteService {
|
||||
|
||||
void updateLeaderboardGroup(String oldName, String newName, String description, List<LeaderboardDTO> leaderboards);
|
||||
|
||||
MultiCompetitorRaceDataDTO getCompetitorsRaceData(RaceIdentifier race, List<Pair<Date, CompetitorDTO>> competitors, long stepSize, DetailType detailType)
|
||||
MultiCompetitorRaceDataDTO getCompetitorsRaceData(RaceIdentifier race, List<Pair<Date, CompetitorDTO>> competitors,
|
||||
Date to, long stepSize, DetailType detailType)
|
||||
throws NoWindException;
|
||||
}
|
||||
+1
-1
@@ -283,6 +283,6 @@ public interface SailingServiceAsync {
|
||||
* returned.<br />
|
||||
* Returns <code>null</code>, if <code>race</code> isn't tracked.
|
||||
*/
|
||||
void getCompetitorsRaceData(RaceIdentifier race, List<Pair<Date,CompetitorDTO>> competitorsToLoad, long stepSize,
|
||||
void getCompetitorsRaceData(RaceIdentifier race, List<Pair<Date,CompetitorDTO>> competitorsToLoad, Date to, long stepSize,
|
||||
DetailType detailType, AsyncCallback<MultiCompetitorRaceDataDTO> callback);
|
||||
}
|
||||
+6
-5
@@ -192,19 +192,20 @@ implements CompetitorSelectionChangeListener, RaceSelectionChangeListener, TimeL
|
||||
chartData = new MultiCompetitorRaceDataDTO(getDataToShow());
|
||||
}
|
||||
|
||||
final ArrayList<Pair<Date, CompetitorDTO>> competitorsToLoad = new ArrayList<Pair<Date, CompetitorDTO>>();
|
||||
final ArrayList<Pair<Date, CompetitorDTO>> dataQuery = new ArrayList<Pair<Date, CompetitorDTO>>();
|
||||
for (CompetitorDTO competitor : getVisibleCompetitors()) {
|
||||
Date chartDataDateOfNewestData = chartData.getDateOfNewestData();
|
||||
if (!chartData.contains(competitor)) {
|
||||
competitorsToLoad.add(new Pair<Date, CompetitorDTO>(new Date(0), competitor));
|
||||
dataQuery.add(new Pair<Date, CompetitorDTO>(new Date(0), competitor));
|
||||
} else if (chartData.getCompetitorData(competitor).getDateOfNewestData().before(chartDataDateOfNewestData)) {
|
||||
Date competitorDateOfNewestData = chartData.getCompetitorData(competitor).getDateOfNewestData();
|
||||
competitorsToLoad.add(new Pair<Date, CompetitorDTO>(new Date(competitorDateOfNewestData.getTime() + getStepSize()), competitor));
|
||||
dataQuery.add(new Pair<Date, CompetitorDTO>(new Date(competitorDateOfNewestData.getTime() + getStepSize()), competitor));
|
||||
}
|
||||
}
|
||||
|
||||
sailingService.getCompetitorsRaceData(getSelectedRace(), competitorsToLoad, getStepSize(),
|
||||
getDataToShow(), new AsyncCallback<MultiCompetitorRaceDataDTO>() {
|
||||
sailingService.getCompetitorsRaceData(getSelectedRace(), dataQuery, new Date(System.currentTimeMillis()
|
||||
- timer.getLivePlayDelayInMillis()), getStepSize(), getDataToShow(),
|
||||
new AsyncCallback<MultiCompetitorRaceDataDTO>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
||||
+3
-2
@@ -1390,12 +1390,13 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
|
||||
@Override
|
||||
public MultiCompetitorRaceDataDTO getCompetitorsRaceData(RaceIdentifier race, List<Pair<Date, CompetitorDTO>> competitorsQuery,
|
||||
long stepSize, DetailType detailType) throws NoWindException {
|
||||
Date to, long stepSize, DetailType detailType) throws NoWindException {
|
||||
MultiCompetitorRaceDataDTO data = null;
|
||||
TrackedRace trackedRace = getExistingTrackedRace(race);
|
||||
if (trackedRace != null) {
|
||||
TimePoint endTime = to != null ? new MillisecondsTimePoint(to) : trackedRace.getTimePointOfNewestEvent();
|
||||
data = getMultiCompetitorRaceDataDTO(trackedRace, competitorsQuery, trackedRace.getStart(),
|
||||
trackedRace.getTimePointOfNewestEvent(), stepSize, detailType);
|
||||
endTime, stepSize, detailType);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user