-
Notifications
You must be signed in to change notification settings - Fork 11
Extend get guestbooks use case with stats and Download responses #449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ekraffmiller
merged 11 commits into
develop
from
448-add-usage-and-response-counts-to-get-guestbooks-use-case
Jun 10, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
96b99ac
feat: extend guestbook with counts
ChengShi-1 de17e97
fix: integration tests
ChengShi-1 6343e69
fix: add use case of downloading responses
ChengShi-1 8ac4f89
fix: lint error
ChengShi-1 8c66e14
update changelog and useCase.md
ChengShi-1 b2ba964
feat: update includeInherited guestbooks queryparam
ChengShi-1 74edeaa
fix: change dataverseId to collectionId, and update GetGuestbookRespo…
ChengShi-1 a84e7f0
Merge branch 'develop' into 448-add-usage-and-response-counts-to-get-…
ChengShi-1 0576b3f
chore: fix lowercases to Uppercases in the naming
ChengShi-1 d447d3f
chore: fix lint
ChengShi-1 46b12b0
fix: add pagination info to return result
ChengShi-1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { Guestbook } from '../models/Guestbook' | ||
| import { GuestbookResponse } from '../models/GuestbookResponse' | ||
|
|
||
| export interface GuestbookResponsesDTO { | ||
| guestbook: Guestbook | ||
| responses: GuestbookResponse[] | ||
| pagination?: GuestbookResponsesPaginationDTO | ||
| } | ||
|
|
||
| export interface GuestbookResponsesPaginationDTO { | ||
| next?: string | ||
| totalResponses: number | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| export interface GuestbookResponse { | ||
| id: number | ||
| dataset: string | ||
| datasetPid: string | ||
| date: string | ||
| type: EventType | ||
| fileName?: string | ||
| fileId?: number | ||
| filePid?: string | ||
| userName: string | ||
| email?: string | ||
| institution?: string | ||
| position?: string | ||
| customQuestions?: GuestbookResponseCustomQuestion[] | ||
| } | ||
|
|
||
| export interface GuestbookResponseCustomQuestion { | ||
| question: string | ||
| response: string | ||
| } | ||
|
|
||
| export interface GuestbookResponseSubset { | ||
| guestbookResponses: GuestbookResponse[] | ||
| totalGuestbookResponseCount: number | ||
| } | ||
|
|
||
| export enum EventType { | ||
| ACCESS_REQUEST = 'AccessRequest', | ||
| DOWNLOAD = 'Download', | ||
| SUBSET = 'Subset', | ||
| EXPLORE = 'Explore' | ||
| } |
16 changes: 15 additions & 1 deletion
16
src/guestbooks/domain/repositories/IGuestbooksRepository.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/guestbooks/domain/useCases/DownloadGuestbookResponsesByCollectionId.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { UseCase } from '../../../core/domain/useCases/UseCase' | ||
| import { IGuestbooksRepository } from '../repositories/IGuestbooksRepository' | ||
|
|
||
| export class DownloadGuestbookResponsesByCollectionId implements UseCase<string> { | ||
| constructor(private readonly guestbooksRepository: IGuestbooksRepository) {} | ||
|
|
||
| /** | ||
| * Downloads all guestbook responses for a collection. | ||
| * | ||
| * @param {number | string} collectionIdOrAlias - Collection alias/identifier or numeric database id. | ||
| * @returns {Promise<string>} Raw response body returned by the Dataverse API. | ||
| */ | ||
| async execute(collectionIdOrAlias: number | string): Promise<string> { | ||
| return await this.guestbooksRepository.downloadGuestbookResponsesByCollectionId( | ||
| collectionIdOrAlias | ||
| ) | ||
| } | ||
| } |
20 changes: 20 additions & 0 deletions
20
src/guestbooks/domain/useCases/DownloadGuestbookResponsesOfAGuestbook.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { UseCase } from '../../../core/domain/useCases/UseCase' | ||
| import { IGuestbooksRepository } from '../repositories/IGuestbooksRepository' | ||
|
|
||
| export class DownloadGuestbookResponsesOfAGuestbook implements UseCase<string> { | ||
| constructor(private readonly guestbooksRepository: IGuestbooksRepository) {} | ||
|
|
||
| /** | ||
|
ChengShi-1 marked this conversation as resolved.
|
||
| * Downloads guestbook responses for one guestbook in a collection. | ||
| * | ||
| * @param {number | string} collectionIdOrAlias - Collection alias/identifier or numeric database id. | ||
| * @param {number} guestbookId - Guestbook identifier to restrict the export. | ||
| * @returns {Promise<string>} Raw response body returned by the Dataverse API. | ||
| */ | ||
| async execute(collectionIdOrAlias: number | string, guestbookId: number): Promise<string> { | ||
| return await this.guestbooksRepository.downloadGuestbookResponsesByCollectionId( | ||
| collectionIdOrAlias, | ||
| guestbookId | ||
| ) | ||
| } | ||
| } | ||
23 changes: 23 additions & 0 deletions
23
src/guestbooks/domain/useCases/GetGuestbookResponsesByGuestbookId.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { UseCase } from '../../../core/domain/useCases/UseCase' | ||
| import { GuestbookResponseSubset } from '../models/GuestbookResponse' | ||
| import { IGuestbooksRepository } from '../repositories/IGuestbooksRepository' | ||
|
|
||
| export class GetGuestbookResponsesByGuestbookId implements UseCase<GuestbookResponseSubset> { | ||
| constructor(private readonly guestbooksRepository: IGuestbooksRepository) {} | ||
|
|
||
| /** | ||
| * Returns paginated guestbook responses for one guestbook. | ||
| * | ||
| * @param {number} guestbookId - Guestbook identifier. | ||
| * @param {number} limit - Maximum number of responses to return. | ||
| * @param {number} offset - Number of responses to skip. | ||
| * @returns {Promise<GuestbookResponseSubset>} | ||
| */ | ||
| async execute(guestbookId: number, limit = 10, offset = 0): Promise<GuestbookResponseSubset> { | ||
| return await this.guestbooksRepository.getGuestbookResponsesByGuestbookId( | ||
| guestbookId, | ||
| limit, | ||
| offset | ||
| ) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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😃