-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b9c97e7
commit 1816c1f
Showing
6 changed files
with
159 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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 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,56 @@ | ||
import {DatasetTerm, StudyTerm, UserTerm} from '../../src/types/model'; | ||
|
||
export const makeUserTerm = (overrides: Partial<UserTerm> = {}): UserTerm => ({ | ||
userId: 0, | ||
displayName: 'some name', | ||
institution: { | ||
id: 0, | ||
name: 'some name', | ||
}, | ||
...overrides, | ||
}); | ||
|
||
export const makeStudyTerm = (overrides: Partial<StudyTerm> = {}): StudyTerm => ({ | ||
description: 'description', | ||
studyName: 'name', | ||
studyId: 0, | ||
phsId: 'phsid', | ||
phenotype: 'phenotype', | ||
species: 'species', | ||
piName: 'pi name', | ||
dataSubmitterEmail: 'data submitter email', | ||
dataSubmitterId: 0, | ||
dataCustodianEmail: ['data custodian email'], | ||
publicVisibility: false, | ||
dataTypes: ['data type'], | ||
...overrides | ||
}); | ||
|
||
export const makeDatasetTerm = (overrides: Partial<DatasetTerm> = {}): DatasetTerm => ({ | ||
datasetId: 0, | ||
createUserId: 0, | ||
createUserDisplayName: 'user', | ||
datasetIdentifier: 'DUOS-123456', | ||
deletable: true, | ||
datasetName: 'dataset', | ||
participantCount: 1, | ||
dataUse: { | ||
primary: [{code: 'foo', description: 'bar'}], | ||
secondary: [{code: 'foo', description: 'bar'}] | ||
}, | ||
dataLocation: 'somewhere', | ||
url: 'some url', | ||
dacId: 0, | ||
dacApproval: true, | ||
accessManagement: 'access', | ||
approvedUserIds: [0], | ||
study: makeStudyTerm(), | ||
submitter: makeUserTerm(), | ||
updateUser: makeUserTerm(), | ||
dac: { | ||
dacId: 0, | ||
dacName: 'some name', | ||
dacEmail: 'some email', | ||
}, | ||
...overrides | ||
}); |
This file contains 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,28 @@ | ||
import {DatasetTerm} from '../../types/model'; | ||
|
||
export interface FiltersTypes { | ||
accessManagement: string[], | ||
dataUse: string[], | ||
dataType: string[], | ||
dac: string[], | ||
participantCountMin?: number, | ||
participantCountMax?: number, | ||
} | ||
|
||
export const defaultFilters = (datasets: DatasetTerm[]): FiltersTypes => { | ||
const defaultParticipantCountValues = generateDefaultParticipantCountValues(datasets); | ||
return { | ||
accessManagement: [], | ||
dataUse: [], | ||
dataType: [], | ||
dac: [], | ||
participantCountMin: defaultParticipantCountValues.min, | ||
participantCountMax: defaultParticipantCountValues.max, | ||
}; | ||
}; | ||
|
||
export const generateDefaultParticipantCountValues = (datasets: DatasetTerm[]) => datasets.reduce((acc, dataset) => { | ||
return { | ||
max: Math.max(acc.max, dataset.participantCount ? dataset.participantCount : 0), | ||
min: Math.min(acc.min, dataset.participantCount ? dataset.participantCount : Infinity) }; | ||
}, {max: 0, min: Infinity}); |
This file contains 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 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 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