Skip to content

Commit

Permalink
feat: update the file preview fields
Browse files Browse the repository at this point in the history
  • Loading branch information
ChengShi-1 committed Jan 3, 2025
1 parent c420849 commit 724e4bc
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/files/domain/models/FilePreview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ export interface FilePreview {
datasetCitation: string
publicationStatuses: PublicationStatus[]
releaseOrCreateDate: Date
restricted: boolean
canDownloadFile: boolean
categories: string[]
tabularTags?: string[]
variables?: number
observations?: number
}

export interface FilePreviewChecksum {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ export interface FilePreviewPayload {
dataset_citation: string
publicationStatuses: string[]
releaseOrCreateDate: string
restricted: boolean
canDownloadFile: boolean
categories: string[]
tabularTags?: string[]
variables?: number
observations?: number
}

export interface FilePreviewChecksumPayload {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ export const transformFilePreviewPayloadToFilePreview = (
datasetPersistentId: filePreviewPayload.dataset_persistent_id,
datasetCitation: filePreviewPayload.dataset_citation,
publicationStatuses: publicationStatuses,
releaseOrCreateDate: new Date(filePreviewPayload.releaseOrCreateDate)
releaseOrCreateDate: new Date(filePreviewPayload.releaseOrCreateDate),
restricted: filePreviewPayload.restricted,
canDownloadFile: filePreviewPayload.canDownloadFile,
categories: filePreviewPayload.categories,
...(filePreviewPayload.tabularTags && {
tabularTags: filePreviewPayload.tabularTags
}),
...(filePreviewPayload.variables && { variables: filePreviewPayload.variables }),
...(filePreviewPayload.observations && { observations: filePreviewPayload.observations })
}
}
10 changes: 8 additions & 2 deletions test/testHelpers/files/filePreviewHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ export const createFilePreviewModel = (): FilePreview => {
datasetPersistentId: 'test pid1',
datasetCitation: 'test citation',
publicationStatuses: [PublicationStatus.Published],
releaseOrCreateDate: new Date('2023-05-15T08:21:01Z')
releaseOrCreateDate: new Date('2023-05-15T08:21:01Z'),
canDownloadFile: true,
restricted: false,
categories: []
}
return filePreviewModel
}
Expand Down Expand Up @@ -53,6 +56,9 @@ export const createFilePreviewPayload = (): FilePreviewPayload => {
dataset_persistent_id: 'test pid1',
dataset_citation: 'test citation',
publicationStatuses: ['Published'],
releaseOrCreateDate: '2023-05-15T08:21:01Z'
releaseOrCreateDate: '2023-05-15T08:21:01Z',
canDownloadFile: true,
restricted: false,
categories: []
}
}

0 comments on commit 724e4bc

Please sign in to comment.