-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NickAkhmetov/CAT-881 deduplicate errored processed datasets' urls (#3558
- Loading branch information
1 parent
9c5c84e
commit 507ecaa
Showing
3 changed files
with
50 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Append HuBMAP ID to errored datasets' URL anchors to avoid anchor duplication on dataset pages with multiple failed processing attempts. |
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,42 @@ | ||
import { datasetSectionId } from './utils'; | ||
|
||
const prefix = 'prefix'; | ||
|
||
describe('datasetSectionId', () => { | ||
it('should format the dataset section id correctly', () => { | ||
const dataset = { | ||
pipeline: 'pipeline', | ||
hubmap_id: 'hubmap_id', | ||
status: 'status', | ||
}; | ||
expect(datasetSectionId(dataset, prefix)).toBe('prefix-pipeline-status'); | ||
}); | ||
it('Should include the hubmap id if the pipeline is missing', () => { | ||
const dataset = { | ||
hubmap_id: 'hubmap_id', | ||
status: 'status', | ||
}; | ||
expect(datasetSectionId(dataset, prefix)).toBe('prefix-hubmap_id-status'); | ||
}); | ||
it('should include the pipeline and hubmap_id if the pipeline is errored', () => { | ||
const dataset = { | ||
pipeline: 'pipeline', | ||
hubmap_id: 'hubmap_id', | ||
status: 'error', | ||
}; | ||
expect(datasetSectionId(dataset, prefix)).toBe('prefix-pipeline-error-hubmap_id'); | ||
}); | ||
it('should generate unique ids for different errored datasets', () => { | ||
const dataset1 = { | ||
pipeline: 'pipeline', | ||
hubmap_id: 'hubmap_id', | ||
status: 'error', | ||
}; | ||
const dataset2 = { | ||
pipeline: 'pipeline', | ||
hubmap_id: 'hubmap_id_2', | ||
status: 'error', | ||
}; | ||
expect(datasetSectionId(dataset1, prefix)).not.toBe(datasetSectionId(dataset2, prefix)); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,11 +1,16 @@ | ||
import { ProcessedDatasetInfo } from './hooks'; | ||
|
||
const potentialDuplicateStates = ['error']; | ||
|
||
export function datasetSectionId( | ||
dataset: Pick<ProcessedDatasetInfo, 'pipeline' | 'hubmap_id' | 'status'>, | ||
dataset: Pick<ProcessedDatasetInfo, 'hubmap_id' | 'status'> & { pipeline?: string }, | ||
prefix = '', | ||
) { | ||
const { pipeline, hubmap_id, status } = dataset; | ||
const formattedDatasetIdentifier = (pipeline ?? hubmap_id).replace(/\s/g, ''); | ||
const formattedStatus = status.replace(/\s/g, ''); | ||
return `${prefix}-${encodeURIComponent(formattedDatasetIdentifier)}-${encodeURIComponent(formattedStatus)}`.toLowerCase(); | ||
const deduplicatedFormattedStatus = potentialDuplicateStates.includes(formattedStatus.toLowerCase()) | ||
? `${formattedStatus}-${hubmap_id}` | ||
: formattedStatus; | ||
return `${prefix}-${encodeURIComponent(formattedDatasetIdentifier)}-${encodeURIComponent(deduplicatedFormattedStatus)}`.toLowerCase(); | ||
} |