-
Notifications
You must be signed in to change notification settings - Fork 10
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
5
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
5 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 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
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,5 @@ | ||
| export interface GuestbookResponse { | ||
| [key: string]: unknown | ||
| guestbookId?: number | ||
| dataverseId?: number | ||
| } |
14 changes: 13 additions & 1 deletion
14
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
20 changes: 20 additions & 0 deletions
20
src/guestbooks/domain/useCases/DownloadGuestbookResponsesByDataverseId.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 DownloadGuestbookResponsesByDataverseId implements UseCase<string> { | ||
| constructor(private readonly guestbooksRepository: IGuestbooksRepository) {} | ||
|
|
||
| /** | ||
| * Downloads all guestbook responses for a dataverse collection. | ||
| * | ||
| * The dataverse 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} dataverseId - Dataverse alias/identifier or numeric database id. | ||
| * @returns {Promise<string>} Raw response body returned by the Dataverse API. | ||
| */ | ||
| async execute(dataverseId: number | string): Promise<string> { | ||
| return await this.guestbooksRepository.downloadGuestbookResponsesByDataverseId(dataverseId) | ||
| } | ||
| } |
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 dataverse collection. | ||
| * | ||
| * The dataverse 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} dataverseId - Dataverse 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(dataverseId: number | string, guestbookId: number): Promise<string> { | ||
| return await this.guestbooksRepository.downloadGuestbookResponsesByDataverseId( | ||
| dataverseId, | ||
| guestbookId | ||
| ) | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/guestbooks/domain/useCases/GetGuestbookResponsesByDataverseId.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,17 @@ | ||
| import { UseCase } from '../../../core/domain/useCases/UseCase' | ||
| import { GuestbookResponse } from '../models/GuestbookResponse' | ||
| import { IGuestbooksRepository } from '../repositories/IGuestbooksRepository' | ||
|
|
||
| export class GetGuestbookResponsesByDataverseId implements UseCase<GuestbookResponse[]> { | ||
| constructor(private readonly guestbooksRepository: IGuestbooksRepository) {} | ||
|
|
||
| /** | ||
| * Returns all guestbook responses for a dataverse collection. | ||
| * | ||
| * @param {number | string} dataverseId - Dataverse identifier. | ||
| * @returns {Promise<GuestbookResponse[]>} | ||
| */ | ||
| async execute(dataverseId: number | string): Promise<GuestbookResponse[]> { | ||
| return await this.guestbooksRepository.getGuestbookResponsesByDataverseId(dataverseId) | ||
| } | ||
| } |
21 changes: 21 additions & 0 deletions
21
src/guestbooks/domain/useCases/GetGuestbookResponsesOfAGuestbook.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,21 @@ | ||
| import { UseCase } from '../../../core/domain/useCases/UseCase' | ||
| import { GuestbookResponse } from '../models/GuestbookResponse' | ||
| import { IGuestbooksRepository } from '../repositories/IGuestbooksRepository' | ||
|
|
||
| export class GetGuestbookResponsesOfAGuestbook implements UseCase<GuestbookResponse[]> { | ||
| constructor(private readonly guestbooksRepository: IGuestbooksRepository) {} | ||
|
|
||
| /** | ||
| * Returns guestbook responses for one guestbook in a dataverse collection. | ||
| * | ||
| * @param {number | string} dataverseId - Dataverse identifier. | ||
| * @param {number} guestbookId - Guestbook identifier filter. | ||
| * @returns {Promise<GuestbookResponse[]>} | ||
| */ | ||
| async execute(dataverseId: number | string, guestbookId: number): Promise<GuestbookResponse[]> { | ||
| return await this.guestbooksRepository.getGuestbookResponsesByDataverseId( | ||
| dataverseId, | ||
| guestbookId | ||
| ) | ||
| } | ||
| } |
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
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.