Skip to content

Commit f3bfe55

Browse files
committed
change ignoreStats to includeStats
1 parent 51d145e commit f3bfe55

5 files changed

Lines changed: 10 additions & 8 deletions

File tree

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
## API Enhancement
2-
API call to `/api/guestbooks/{dataverseAlias}/list` will now include `"usageCount":#` and `"responseCount":#` in the response.
3-
By adding the query param "ignoreStats=true" these values can be excluded for faster response.
2+
API call to `/api/guestbooks/{dataverseAlias}/list` can now include `"usageCount":#` and `"responseCount":#` in the response by adding the query param "includeStats=true".

doc/sphinx-guides/source/api/native-api.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,7 @@ The fully expanded example above (without environment variables) looks like this
12391239
12401240
curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" "https://demo.dataverse.org/api/guestbooks/root/list"
12411241
1242-
.. note:: By adding the query param "ignoreStats=true" `usageCount` and `responseCount` values can be excluded for faster response.
1242+
.. note:: By adding the query param "includeStats=true" `usageCount` and `responseCount` values can be added to the response.
12431243
12441244
Get a Guestbook for a Dataverse Collection
12451245
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/main/java/edu/harvard/iq/dataverse/api/Guestbooks.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public Response getGuestbook(@Context ContainerRequestContext crc, @PathParam("i
6060
@GET
6161
@AuthRequired
6262
@Path("{identifier}/list")
63-
public Response getGuestbooks(@Context ContainerRequestContext crc, @PathParam("identifier") String identifier, @QueryParam("ignoreStats") boolean ignoreStats) {
63+
public Response getGuestbooks(@Context ContainerRequestContext crc, @PathParam("identifier") String identifier, @QueryParam("includeStats") boolean includeStats) {
6464
return response( req -> {
6565
Dataverse dataverse = findDataverseOrDie(identifier);
6666
final Long dataverseId = dataverse.getId();
@@ -71,8 +71,7 @@ public Response getGuestbooks(@Context ContainerRequestContext crc, @PathParam("
7171
JsonArrayBuilder guestbookArray = Json.createArrayBuilder();
7272
JsonPrinter jsonPrinter = new JsonPrinter();
7373
for (Guestbook gb : guestbooks) {
74-
// default is to include the stats. Ignore the stats for a faster reply if they are not needed
75-
if (!ignoreStats) {
74+
if (includeStats) {
7675
gb.setUsageCount(guestbookService.findCountUsages(gb.getId(), dataverseId));
7776
gb.setResponseCount(guestbookResponseService.findCountByGuestbookId(gb.getId(), dataverseId));
7877
}

src/test/java/edu/harvard/iq/dataverse/api/FilesIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4062,7 +4062,7 @@ public void testDownloadFileWithGuestbookResponse() throws IOException, JsonPars
40624062
assertEquals(OK.getStatusCode(), signedUrlResponse.getStatusCode());
40634063

40644064
// Verify that the guestbook has proper stats
4065-
Response guestbookListResponse = UtilIT.getGuestbooks(dataverseAlias, ownerApiToken);
4065+
Response guestbookListResponse = UtilIT.getGuestbooks(dataverseAlias, ownerApiToken, true);
40664066
guestbookListResponse.prettyPrint();
40674067
guestbookListResponse.then().assertThat()
40684068
.statusCode(OK.getStatusCode())

src/test/java/edu/harvard/iq/dataverse/api/UtilIT.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,9 +612,13 @@ static Response getGuestbook(Long guestbookId, String apiToken) {
612612
}
613613

614614
static Response getGuestbooks(String dataverseAlias, String apiToken) {
615+
return getGuestbooks(dataverseAlias, apiToken, false);
616+
}
617+
static Response getGuestbooks(String dataverseAlias, String apiToken, boolean includeStats) {
618+
String params = "?includeStats=" + includeStats;
615619
RequestSpecification requestSpec = given()
616620
.header(API_TOKEN_HTTP_HEADER, apiToken);
617-
return requestSpec.get("/api/guestbooks/" + dataverseAlias + "/list" );
621+
return requestSpec.get("/api/guestbooks/" + dataverseAlias + "/list" + params );
618622
}
619623

620624
static Response enableGuestbook(String dataverseAlias, Long guestbookId, String apiToken, String enable) {

0 commit comments

Comments
 (0)