bug6016: added timepoint-ms and lastScoringUpdate-ms fields to /leaderboardgroups/{name|id} response

This commit is contained in:
Axel Uhl committed 2024-06-11 10:40:16 +02:00
1 parent e5835482c4
commit 4576450303
4 files changed
+16 -3

No files matched your search

@@ -14,6 +14,7 @@ public interface LeaderboardNameConstants {
static final String SCORINGSCHEME = "scoringScheme";
static final String SCORINGCOMMENT = "scoringComment";
static final String LASTSCORINGUPDATE = "lastScoringUpdate";
static final String LASTSCORINGUPDATE_MILLIS = "lastScoringUpdate-ms";
static final String REGATTANAME = "regattaName";
static final String SERIES = "series";
static final String ISMEDALSERIES = "isMedalSeries";
@@ -5,6 +5,14 @@
<div id="mainContent">
<h4 class="articleHeadline">What's New - SAP Sailing Analytics</h4>
<div class="innerContent">
<h5 class="articleSubheadline">June 2024</h5>
<ul class="bulletList">
<li>Added the <tt>timepoint-ms</tt> and <tt>lastScoringUpdate-ms</tt> fields to the
<tt>/sailingserver/api/v1/leaderboardgroups/{id|name}</tt>
response which reports the time point as the number of milliseconds since the epoch (1970-01-01T00:00:00Z, "Unix time").
The <tt>timepoint</tt> and <tt>lastScoringUpdate</tt> fields' format is not easily machine-readable,
but we're not changing the format for reasons of backward compatibility.</li>
</ul>
<h5 class="articleSubheadline">April 2024</h5>
<ul class="bulletList">
<li>Added the <tt>trueheading-deg</tt> field to the competitor GPS fix export if the tracker has provided it.</li>
@@ -6,6 +6,7 @@ public interface LeaderboardGroupConstants {
String DISPLAYNAME = "displayName";
String DESCRIPTION = "description";
String TIMEPOINT = "timepoint";
String TIMEPOINT_MILLIS = "timepoint-ms";
String EVENTS = "events";
String LEADERBOARDS = "leaderboards";
}
@@ -139,15 +139,16 @@ public class LeaderboardGroupsResource extends AbstractSailingServerResource {
.type(MediaType.TEXT_PLAIN).build();
} else {
if (getSecurityService().hasCurrentUserReadPermission(leaderboardGroup)) {
TimePoint timePoint = MillisecondsTimePoint.now();
JSONObject jsonLeaderboardGroup = new JSONObject();
final TimePoint timePoint = MillisecondsTimePoint.now();
final JSONObject jsonLeaderboardGroup = new JSONObject();
jsonLeaderboardGroup.put(LeaderboardGroupConstants.NAME, leaderboardGroup.getName());
jsonLeaderboardGroup.put(LeaderboardGroupConstants.ID, leaderboardGroup.getId().toString());
jsonLeaderboardGroup.put(LeaderboardGroupConstants.DISPLAYNAME, leaderboardGroup.getDisplayName());
jsonLeaderboardGroup.put(LeaderboardGroupConstants.DESCRIPTION, leaderboardGroup.getDescription());
jsonLeaderboardGroup.put(LeaderboardGroupConstants.TIMEPOINT, timePoint.toString());
jsonLeaderboardGroup.put(LeaderboardGroupConstants.TIMEPOINT_MILLIS, timePoint.asMillis());
final Set<Event> eventsReferencingLeaderboardGroup = new HashSet<>();
JSONArray idsOfEventsReferencingLeaderboardGroup = new JSONArray();
final JSONArray idsOfEventsReferencingLeaderboardGroup = new JSONArray();
for (final Event event : getService().getAllEvents()) {
if (Util.contains(event.getLeaderboardGroups(), leaderboardGroup)) {
eventsReferencingLeaderboardGroup.add(event);
@@ -173,6 +174,8 @@ public class LeaderboardGroupsResource extends AbstractSailingServerResource {
TimePoint lastUpdateTimepoint = scoreCorrection.getTimePointOfLastCorrectionsValidity();
jsonLeaderboard.put(LeaderboardNameConstants.LASTSCORINGUPDATE,
lastUpdateTimepoint != null ? lastUpdateTimepoint.asDate().toString() : null);
jsonLeaderboard.put(LeaderboardNameConstants.LASTSCORINGUPDATE_MILLIS,
lastUpdateTimepoint != null ? lastUpdateTimepoint.asMillis() : null);
} else {
jsonLeaderboard.put(LeaderboardNameConstants.SCORINGCOMMENT, null);
jsonLeaderboard.put(LeaderboardNameConstants.LASTSCORINGUPDATE, null);