-
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
Open
ChengShi-1
wants to merge
10
commits into
develop
Choose a base branch
from
448-add-usage-and-response-counts-to-get-guestbooks-use-case
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 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 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,27 @@ | ||
| 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 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
22 changes: 22 additions & 0 deletions
22
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,22 @@ | ||
| 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. | ||
| * | ||
| * The collection can be identified by either its alias/identifier or numeric database id. | ||
| * The returned string is the raw response body from the Dataverse API, which is typically | ||
| * saved by callers as a CSV file or printed directly. | ||
| * | ||
| * @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 | ||
| ) | ||
| } | ||
| } |
24 changes: 24 additions & 0 deletions
24
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,24 @@ | ||
| import { UseCase } from '../../../core/domain/useCases/UseCase' | ||
| import { IGuestbooksRepository } from '../repositories/IGuestbooksRepository' | ||
|
|
||
| export class DownloadGuestbookResponsesOfAGuestbook implements UseCase<string> { | ||
| constructor(private readonly guestbooksRepository: IGuestbooksRepository) {} | ||
|
|
||
| /** | ||
| * Downloads guestbook responses for one guestbook in a collection. | ||
| * | ||
| * The collection can be identified by either its alias/identifier or numeric database id. | ||
| * The returned string is the raw response body from the Dataverse API, which is typically | ||
| * saved by callers as a CSV file or printed directly. | ||
| * | ||
| * @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 { GuestbookResponse } from '../models/GuestbookResponse' | ||
| import { IGuestbooksRepository } from '../repositories/IGuestbooksRepository' | ||
|
|
||
| export class GetGuestbookResponsesByGuestbookId implements UseCase<GuestbookResponse[]> { | ||
| constructor(private readonly guestbooksRepository: IGuestbooksRepository) {} | ||
|
|
||
| /** | ||
| * Returns 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<GuestbookResponse[]>} | ||
| */ | ||
| async execute(guestbookId: number, limit = 10, offset = 0): Promise<GuestbookResponse[]> { | ||
| 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.
Uh oh!
There was an error while loading. Please reload this page.