Skip to content

Commit 3cc946e

Browse files
committed
feat: parsing of pdf link candidates
1 parent 3af393c commit 3cc946e

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

vis/js/dataprocessing/managers/DataManager.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
getListLink,
1515
getOpenAccessLink,
1616
getOutlink,
17+
getPdfLinkCandidatesFromDuplicates,
1718
getValueOrZero,
1819
getVisibleMetric,
1920
isOpenAccess,
@@ -257,6 +258,9 @@ class DataManager {
257258
paper.oa_link = getOpenAccessLink(paper, this.config);
258259
paper.outlink = getOutlink(paper, this.config);
259260
paper.list_link = getListLink(paper, this.config, this.context);
261+
262+
paper.pdf_link_candidates_from_duplicates =
263+
getPdfLinkCandidatesFromDuplicates(paper);
260264
}
261265

262266
__parseComments(paper: any) {

vis/js/types/models/paper.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ export interface CommonPaperDataForAllIntegrations {
6868
zoomedY: number;
6969
zoomedWidth: number;
7070
zoomedHeight: number;
71+
72+
pdf_link_candidates_from_duplicates: string[] | null;
7173
}
7274

7375
export interface PubmedPaper extends CommonPaperDataForAllIntegrations {

vis/js/utils/data.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,25 @@ export const getListLink = (paper, config, context) => {
285285
return {};
286286
};
287287

288+
/**
289+
* Parses the paper's pdf link candidates from duplicates into an array of strings.
290+
*
291+
* @param {object} paper paper object
292+
*
293+
* @returns array of strings or null if no candidates are found
294+
*/
295+
export const getPdfLinkCandidatesFromDuplicates = (paper): string[] | null => {
296+
if (
297+
typeof paper.pdf_link_candidates_from_duplicates !== "string" ||
298+
!paper.pdf_link_candidates_from_duplicates
299+
) {
300+
return null;
301+
}
302+
303+
const links = paper.pdf_link_candidates_from_duplicates.split(";");
304+
return links.length > 0 ? links : null;
305+
};
306+
288307
/**
289308
* Parses the paper's authors string into an object array.
290309
*

vis/test/data/papers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ const MOCK_COMMON_PAPER_DATA: CommonPaperDataForAllIntegrations = {
5555
zoomedY: 1,
5656
zoomedWidth: 1,
5757
zoomedHeight: 1,
58+
59+
pdf_link_candidates_from_duplicates: null,
5860
};
5961

6062
export const MOCK_BASE_PAPER_DATA: BasePaper = {

0 commit comments

Comments
 (0)