Skip to content

Extend get guestbooks use case with stats and Download responses#449

Merged
ekraffmiller merged 11 commits into
developfrom
448-add-usage-and-response-counts-to-get-guestbooks-use-case
Jun 10, 2026
Merged

Extend get guestbooks use case with stats and Download responses#449
ekraffmiller merged 11 commits into
developfrom
448-add-usage-and-response-counts-to-get-guestbooks-use-case

Conversation

@ChengShi-1

@ChengShi-1 ChengShi-1 commented May 11, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

  • Get Guestbooks By Collection Id: Added optional includeStats and includeInherited support to getGuestbooksByCollectionId.
  • write use cases of downloading all responses of a collection or download responses of a guestbook

Which issue(s) this PR closes:

Related Dataverse PRs:

Special notes for your reviewer:

Test failed about storage drive, so I also copy pastes a CollectionHelper.ts from this PR. waiting to be merged
https://github.com/IQSS/dataverse-client-javascript/pull/431/changes#diff-edac108c1a43d5773116d19797d04ecdf890fc97b5cf83ce2d56d38b9a7aca18

Suggestions on how to test this:

Is there a release notes or changelog update needed for this change?:

Additional documentation:

@ChengShi-1 ChengShi-1 linked an issue May 11, 2026 that may be closed by this pull request
@github-actions github-actions Bot added FY26 Sprint 23 FY26 Sprint 23 (2026-05-06 - 2026-05-20) GREI Re-arch GREI re-architecture-related labels May 11, 2026
@ChengShi-1 ChengShi-1 added the Size: 3 A percentage of a sprint. 2.1 hours. label May 11, 2026
@ChengShi-1 ChengShi-1 moved this to Ready for Review ⏩ in IQSS Dataverse Project May 11, 2026
@ChengShi-1 ChengShi-1 marked this pull request as ready for review May 11, 2026 21:08
Copilot AI review requested due to automatic review settings May 11, 2026 21:08
@ChengShi-1 ChengShi-1 moved this from Ready for Review ⏩ to In Progress 💻 in IQSS Dataverse Project May 11, 2026
@ChengShi-1 ChengShi-1 self-assigned this May 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds optional guestbook usage/response statistics support to the “get guestbooks by collection” flow, aligning the client with the Dataverse API enhancement needed for the Manage Guestbooks UI.

Changes:

  • Extended getGuestbooksByCollectionId to accept an optional includeStats flag and send it as a query parameter when enabled.
  • Updated the Guestbook domain model to optionally expose usageCount and responseCount.
  • Added/updated unit + integration tests, plus documentation and changelog entries.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/unit/guestbooks/GuestbooksRepository.test.ts New unit coverage for repository query param behavior and error handling.
test/unit/guestbooks/GetGuestbooksByCollectionId.test.ts Adds unit coverage for the use case passing includeStats.
test/integration/guestbooks/GuestbooksRepository.test.ts Adds integration coverage for listing stats and verifying count changes via assignment + guest response submission.
src/guestbooks/infra/repositories/GuestbooksRepository.ts Adds includeStats param and forwards it as query params when true.
src/guestbooks/domain/useCases/GetGuestbooksByCollectionId.ts Extends use case API to accept includeStats.
src/guestbooks/domain/repositories/IGuestbooksRepository.ts Updates repository interface to include optional includeStats.
src/guestbooks/domain/models/Guestbook.ts Adds optional usageCount and responseCount fields.
docs/useCases.md Documents the new includeStats parameter and updates example usage.
CHANGELOG.md Adds an Unreleased entry describing the new includeStats support.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/guestbooks/domain/useCases/GetGuestbooksByCollectionId.ts Outdated
@ChengShi-1 ChengShi-1 changed the title Extend get guestbooks use case with stats Extend get guestbooks use case with stats and Download responses May 18, 2026
@ChengShi-1 ChengShi-1 removed their assignment May 19, 2026
@ChengShi-1 ChengShi-1 moved this from In Progress 💻 to Ready for Review ⏩ in IQSS Dataverse Project May 19, 2026
@cmbz cmbz added the FY26 Sprint 24 FY26 Sprint 24 (2026-05-20 - 2026-06-03) label May 21, 2026
@cmbz cmbz added the FY26 Sprint 25 FY26 Sprint 25 (2026-06-03 - 2026-06-17) label Jun 3, 2026
@ekraffmiller ekraffmiller self-assigned this Jun 8, 2026
@ekraffmiller ekraffmiller moved this from Ready for Review ⏩ to In Review 🔎 in IQSS Dataverse Project Jun 8, 2026

@ekraffmiller ekraffmiller left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ChengShi-1 I left some comments on the PR, hope it's not too confusing! After going back on forth between the use cases and the API, I think there is actually one more change we need in the API - which I describe in my comment in GetGuestbookResponsesOfAGuestbook. I'm happy to discuss more about it.

Comment thread src/guestbooks/domain/useCases/DownloadGuestbookResponsesByDataverseId.ts Outdated
/**
* Returns guestbook responses for one guestbook in a dataverse collection.
*
* @param {number | string} dataverseId - Dataverse identifier.

@ekraffmiller ekraffmiller Jun 9, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API for getting the responses for a guestbook in JSON form is, for example:
curl -H "X-Dataverse-key:$API_TOKEN" "$SERVER_URL/api/guestbooks/$ID/responses?limit10&offset=0"
So we need to add parameters for limit and offset.
Another thing I noticed though, is that this API doesn't allow us to pass a dataverseId, so it's going to return all guestbook responses regardless of collection. So unfortunately I think we to ask for another change to the API - to be able to pass guestbookId and collectionId and get all the responses for a guestbook within a specific collection, returned in JSON format.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created an issue in dataverse for the api missing IQSS/dataverse#12451

import { GuestbookResponse } from '../models/GuestbookResponse'
import { IGuestbooksRepository } from '../repositories/IGuestbooksRepository'

export class GetGuestbookResponsesByDataverseId implements UseCase<GuestbookResponse[]> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this use case is needed, we only need to download the csv version of the responses, we don't need an array of JSON for displaying.

@ekraffmiller ekraffmiller left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! just need to update the return type of GetGuestbookResponsesByGuestbookId to support pagination.

Comment thread docs/useCases.md
const limit = 10
const offset = 0

getGuestbookResponsesByGuestbookId

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API will return pagination info as well, so the return type should be GustbookSubset, containing the array of Guestbook items, and the total count, similar to how we handle pagination for other objects

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added. Thanks for catching this😃

@ekraffmiller ekraffmiller removed their assignment Jun 10, 2026

@ekraffmiller ekraffmiller left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the updates, looks good!

@github-project-automation github-project-automation Bot moved this from In Review 🔎 to Ready for QA ⏩ in IQSS Dataverse Project Jun 10, 2026
@ekraffmiller ekraffmiller merged commit 74ec1ef into develop Jun 10, 2026
5 checks passed
@github-project-automation github-project-automation Bot moved this from Ready for QA ⏩ to Merged 🚀 in IQSS Dataverse Project Jun 10, 2026
@ChengShi-1 ChengShi-1 removed their assignment Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FY26 Sprint 23 FY26 Sprint 23 (2026-05-06 - 2026-05-20) FY26 Sprint 24 FY26 Sprint 24 (2026-05-20 - 2026-06-03) FY26 Sprint 25 FY26 Sprint 25 (2026-06-03 - 2026-06-17) GREI Re-arch GREI re-architecture-related Size: 3 A percentage of a sprint. 2.1 hours.

Projects

Status: Merged 🚀

Development

Successfully merging this pull request may close these issues.

Add usage and response counts to get guestbooks use case

4 participants