mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-21 19:50:01 +00:00
in addition to the race column names for which to load details, added a parameter addOverallDetails
that controls whether a leaderboardDTO shall have overall details; the leaderboard cache and the LiveLeaderboardUpdater consider this parameter in how they cache their DTOs.
This commit is contained in:
1 parent
17a16f4ecd
commit
e19209a61c
13 files changed
+118
-71
No files matched your search
+7
-6
@@ -17,7 +17,7 @@ import com.sap.sse.gwt.client.player.Timer;
|
||||
* the logic how differential, incremental leaderboard fetching and transmission works. This helps guarantee the
|
||||
* requirement of {@link IncrementalOrFullLeaderboardDTO#getLeaderboardDTO(LeaderboardDTO)} (only pass <code>null</code>
|
||||
* as the previous leaderboard if <code>null</code> was passed as identifier of the previous leaderboard to
|
||||
* {@link SailingServiceAsync#getLeaderboardByName(String, Date, Collection, String, AsyncCallback)} too.
|
||||
* {@link SailingServiceAsync#getLeaderboardByName(String, Date, Collection, boolean, String, AsyncCallback)} too.
|
||||
* <p>
|
||||
*
|
||||
* When a valid {@link IncrementalOrFullLeaderboardDTO} object is received, the
|
||||
@@ -32,20 +32,22 @@ public class GetLeaderboardByNameAction implements AsyncAction<LeaderboardDTO> {
|
||||
private final String leaderboardName;
|
||||
private final Date date;
|
||||
private final Collection<String> namesOfRacesForWhichToLoadLegDetails;
|
||||
private final boolean addOverallDetails;
|
||||
private final LeaderboardDTO previousLeaderboard;
|
||||
private final StringMessages stringMessages;
|
||||
private final ErrorReporter errorReporter;
|
||||
private final Timer timerToAdjustOffetIn;
|
||||
|
||||
public GetLeaderboardByNameAction(SailingServiceAsync sailingService, String leaderboardName, Date date,
|
||||
final Collection<String> namesOfRacesForWhichToLoadLegDetails, LeaderboardDTO previousLeaderboard,
|
||||
Timer timerToAdjustOffsetIn, ErrorReporter errorReporter, StringMessages stringMessages) {
|
||||
final Collection<String> namesOfRacesForWhichToLoadLegDetails, boolean addOverallDetails,
|
||||
LeaderboardDTO previousLeaderboard, Timer timerToAdjustOffsetIn, ErrorReporter errorReporter, StringMessages stringMessages) {
|
||||
this.sailingService = sailingService;
|
||||
this.errorReporter = errorReporter;
|
||||
this.stringMessages = stringMessages;
|
||||
this.leaderboardName = leaderboardName;
|
||||
this.date = date;
|
||||
this.namesOfRacesForWhichToLoadLegDetails = namesOfRacesForWhichToLoadLegDetails;
|
||||
this.addOverallDetails = addOverallDetails;
|
||||
this.previousLeaderboard = previousLeaderboard;
|
||||
this.timerToAdjustOffetIn = timerToAdjustOffsetIn;
|
||||
}
|
||||
@@ -53,9 +55,8 @@ public class GetLeaderboardByNameAction implements AsyncAction<LeaderboardDTO> {
|
||||
@Override
|
||||
public void execute(final AsyncCallback<LeaderboardDTO> callback) {
|
||||
final long clientTimeWhenRequestWasSent = System.currentTimeMillis();
|
||||
sailingService.getLeaderboardByName(leaderboardName, date, namesOfRacesForWhichToLoadLegDetails,
|
||||
previousLeaderboard==null?null:previousLeaderboard.getId(),
|
||||
new AsyncCallback<IncrementalOrFullLeaderboardDTO>() {
|
||||
sailingService.getLeaderboardByName(leaderboardName, date, namesOfRacesForWhichToLoadLegDetails, addOverallDetails,
|
||||
previousLeaderboard==null?null:previousLeaderboard.getId(), new AsyncCallback<IncrementalOrFullLeaderboardDTO>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
callback.onFailure(caught);
|
||||
|
||||
+2
-1
@@ -125,7 +125,8 @@ public interface SailingService extends RemoteService {
|
||||
public List<String> getLeaderboardNames();
|
||||
|
||||
IncrementalOrFullLeaderboardDTO getLeaderboardByName(String leaderboardName, Date date,
|
||||
Collection<String> namesOfRaceColumnsForWhichToLoadLegDetails, String previousLeaderboardId) throws Exception;
|
||||
Collection<String> namesOfRaceColumnsForWhichToLoadLegDetails, boolean addOverallDetails,
|
||||
String previousLeaderboardId) throws Exception;
|
||||
|
||||
List<StrippedLeaderboardDTO> getLeaderboards();
|
||||
|
||||
|
||||
+1
-1
@@ -172,7 +172,7 @@ public interface SailingServiceAsync {
|
||||
|
||||
void getLeaderboardByName(String leaderboardName, Date date,
|
||||
Collection<String> namesOfRaceColumnsForWhichToLoadLegDetails,
|
||||
String previousLeaderboardId, AsyncCallback<IncrementalOrFullLeaderboardDTO> callback);
|
||||
boolean addOverallDetails, String previousLeaderboardId, AsyncCallback<IncrementalOrFullLeaderboardDTO> callback);
|
||||
|
||||
void getLeaderboardNames(AsyncCallback<List<String>> callback);
|
||||
|
||||
|
||||
+9
-4
@@ -135,7 +135,7 @@ public class LeaderboardPanel extends SimplePanel implements TimeListener, PlayS
|
||||
|
||||
/**
|
||||
* The leaderboard name is used to
|
||||
* {@link SailingServiceAsync#getLeaderboardByName(String, java.util.Date, String[], String, com.google.gwt.user.client.rpc.AsyncCallback)
|
||||
* {@link SailingServiceAsync#getLeaderboardByName(String, java.util.Date, String[], boolean, String, com.google.gwt.user.client.rpc.AsyncCallback)
|
||||
* obtain the leaderboard contents} from the server. It may change in case the leaderboard is renamed.
|
||||
*/
|
||||
private String leaderboardName;
|
||||
@@ -791,7 +791,7 @@ public class LeaderboardPanel extends SimplePanel implements TimeListener, PlayS
|
||||
getSailingService().getLeaderboardByName(getLeaderboardName(),
|
||||
timer.getPlayMode() == PlayModes.Live ? null : getLeaderboardDisplayDate(),
|
||||
/* namesOfRacesForWhichToLoadLegDetails */getNamesOfExpandedRaces(),
|
||||
previousLeaderboard.getId(), new MarkedAsyncCallback<IncrementalOrFullLeaderboardDTO>(
|
||||
shallAddOverallDetails(), previousLeaderboard.getId(), new MarkedAsyncCallback<IncrementalOrFullLeaderboardDTO>(
|
||||
new AsyncCallback<IncrementalOrFullLeaderboardDTO>() {
|
||||
@Override
|
||||
public void onSuccess(IncrementalOrFullLeaderboardDTO result) {
|
||||
@@ -1767,7 +1767,7 @@ public class LeaderboardPanel extends SimplePanel implements TimeListener, PlayS
|
||||
GetLeaderboardByNameAction getLeaderboardByNameAction = new GetLeaderboardByNameAction(sailingService,
|
||||
getLeaderboardName(), useNullAsTimePoint() ? null : date,
|
||||
/* namesOfRacesForWhichToLoadLegDetails */getNamesOfExpandedRaces(),
|
||||
/* previousLeaderboard */ getLeaderboard(), timer, errorReporter, stringMessages);
|
||||
shallAddOverallDetails(), /* previousLeaderboard */ getLeaderboard(), timer, errorReporter, stringMessages);
|
||||
this.asyncActionsExecutor.execute(getLeaderboardByNameAction, LOAD_LEADERBOARD_DATA_CATEGORY,
|
||||
new AsyncCallback<LeaderboardDTO>() {
|
||||
@Override
|
||||
@@ -1820,6 +1820,11 @@ public class LeaderboardPanel extends SimplePanel implements TimeListener, PlayS
|
||||
return namesOfExpandedRaces;
|
||||
}
|
||||
|
||||
private boolean shallAddOverallDetails() {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns <code>leaderboard</code> to {@link #leaderboard} and updates the UI accordingly. Also updates the min/max
|
||||
* values on the columns.
|
||||
@@ -2519,7 +2524,7 @@ public class LeaderboardPanel extends SimplePanel implements TimeListener, PlayS
|
||||
public boolean hasBusyIndicator() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private Iterable<LeaderboardRowDTO> getSelectedRows() {
|
||||
ArrayList<LeaderboardRowDTO> selectedRows = new ArrayList<LeaderboardRowDTO>();
|
||||
for (LeaderboardRowDTO row : getData().getList()) {
|
||||
|
||||
+5
-5
@@ -556,7 +556,6 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
* <p>
|
||||
*
|
||||
* Otherwise, the leaderboard is computed synchronously on the fly.
|
||||
*
|
||||
* @param previousLeaderboardId
|
||||
* if <code>null</code> or no leaderboard with that {@link LeaderboardDTO#getId() ID} is known, a
|
||||
* {@link FullLeaderboardDTO} will be computed; otherwise, an {@link IncrementalLeaderboardDTO} will be
|
||||
@@ -564,8 +563,9 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
*/
|
||||
@Override
|
||||
public IncrementalOrFullLeaderboardDTO getLeaderboardByName(final String leaderboardName, final Date date,
|
||||
final Collection<String> namesOfRaceColumnsForWhichToLoadLegDetails, String previousLeaderboardId)
|
||||
throws NoWindException, InterruptedException, ExecutionException, IllegalArgumentException {
|
||||
final Collection<String> namesOfRaceColumnsForWhichToLoadLegDetails, boolean addOverallDetails,
|
||||
String previousLeaderboardId) throws NoWindException, InterruptedException, ExecutionException,
|
||||
IllegalArgumentException {
|
||||
try {
|
||||
long startOfRequestHandling = System.currentTimeMillis();
|
||||
IncrementalOrFullLeaderboardDTO result = null;
|
||||
@@ -578,7 +578,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
timePoint = new MillisecondsTimePoint(date);
|
||||
}
|
||||
LeaderboardDTO leaderboardDTO = leaderboard.getLeaderboardDTO(timePoint,
|
||||
namesOfRaceColumnsForWhichToLoadLegDetails, getService(), baseDomainFactory);
|
||||
namesOfRaceColumnsForWhichToLoadLegDetails, addOverallDetails, getService(), baseDomainFactory);
|
||||
LeaderboardDTO previousLeaderboardDTO = null;
|
||||
synchronized (leaderboardByNameResultsCacheById) {
|
||||
leaderboardByNameResultsCacheById.put(leaderboardDTO.getId(), leaderboardDTO);
|
||||
@@ -2486,7 +2486,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
switch (detailType) {
|
||||
case REGATTA_TOTAL_POINTS:
|
||||
LeaderboardDTO leaderboardDTO = leaderboard.getLeaderboardDTO(timePoint, Collections.<String> emptyList(),
|
||||
getService(), baseDomainFactory);
|
||||
/* addOverallDetails */ false, getService(), baseDomainFactory);
|
||||
for (RaceColumnDTO raceColumnDTO : leaderboardDTO.getRaceList()) {
|
||||
result.add(getTotalPointsForRaceColumn(leaderboardDTO, raceColumnDTO));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user