Skip to content

Commit

Permalink
Add VOR corrections to version history [elifesciences/enhanced-prepri…
Browse files Browse the repository at this point in the history
  • Loading branch information
nlisgo committed Jul 8, 2024
1 parent f522ecb commit 55c4c6c
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const resources = {
external_timeline_version_title: '$t(timeline_version_title)',
history_version_title: '$t(reviewed_preprint) version {{version}}',
external_history_version_title: '$t(history_version_title)',
external_history_version_title_updated: '$t(external_history_version_title)',
},
elife: {
twitter_handle: '@elife',
Expand All @@ -41,6 +42,7 @@ const resources = {
related_type_podcastChapterEpisode: 'Podcast',
external_timeline_version_title: 'Version of Record',
external_history_version_title: 'Version of Record published',
external_history_version_title_updated: 'Version of Record updated',
review_process_reviewed: '<strong>Not revised:</strong> This Reviewed Preprint includes the authors’ original preprint (without revision), an eLife assessment, public reviews, and a response from the authors (if available).',
review_process_revised: (
'<strong>Revised:</strong> This Reviewed Preprint has been revised by the authors in response to the previous round of peer review; '
Expand Down
64 changes: 64 additions & 0 deletions src/utils/generators/generate-version-history.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ const version3Summary: VersionSummary = {
url: 'https://doi.org/doi-123v3',
};

const version3SummaryWithCorrections: VersionSummary = {
versionIdentifier: '3',
published: new Date('2023-02-09'),
url: 'https://doi.org/doi-123v3',
corrections: [
{
date: new Date('2023-02-10'),
url: 'https://elifesciences.org/articles/1v1',
},
{
date: new Date('2023-02-11'),
url: 'https://elifesciences.org/articles/1v2',
},
],
};

const summariseEnhancedArticleToVersionSummary = (article: EnhancedArticle): VersionSummary => ({
id: article.id,
doi: article.doi,
Expand Down Expand Up @@ -161,4 +177,52 @@ describe('generateVersionHistory', () => {
},
]);
});

it('should generate the correct version history with an external version summary with corrections', () => {
const history = generateVersionHistory({
article: version2,
versions: {
v1: summariseEnhancedArticleToVersionSummary(version1),
v2: summariseEnhancedArticleToVersionSummary(version2),
v3: version3SummaryWithCorrections,
},
});

expect(history).toEqual([
{
date: 'Sun Jan 01 2023',
label: 'Sent for peer review',
},
{
date: 'Mon Jan 02 2023',
label: 'Preprint posted',
url: 'https://doi.org/doi-123',
},
{
label: 'Reviewed Preprint version 1',
url: '/reviewed-preprints/1v1',
date: 'Tue Jan 03 2023',
},
{
label: 'Reviewed Preprint version 2',
url: '/reviewed-preprints/1v2',
date: 'Mon Jan 09 2023',
},
{
label: 'Version of Record published',
url: 'https://doi.org/doi-123v3',
date: 'Thu Feb 09 2023',
},
{
label: 'Version of Record updated',
url: 'https://elifesciences.org/articles/1v1',
date: 'Fri Feb 10 2023',
},
{
label: 'Version of Record updated',
url: 'https://elifesciences.org/articles/1v2',
date: 'Sat Feb 11 2023',
},
]);
});
});
10 changes: 10 additions & 0 deletions src/utils/generators/generate-version-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ export const generateVersionHistory = (version: EnhancedArticleWithVersions): Ve
url: `${isPreprintVersionSummary(current) ? `/reviewed-preprints/${current.id}` : ''}${isExternalVersionSummary(current) ? current.url : ''}`,
date: new Date(current.published).toDateString(),
});

if (isExternalVersionSummary(current) && (current.corrections ?? []).length > 0) {
versions.push(...(current.corrections ?? []).map((correction) => ({
label: i18n.t('external_history_version_title_updated', {
version: +current.versionIdentifier,
}),
url: correction.url,
date: new Date(correction.date).toDateString(),
})));
}
}
return versions;
}, []);
Expand Down

0 comments on commit 55c4c6c

Please sign in to comment.