Skip to content

Commit 897e680

Browse files
authored
Merge pull request #1208 from PathwayCommons/iss961_flex-top-hit
Ignore the score when retrieving from CrossRef.
2 parents e153a1f + 5030a2c commit 897e680

File tree

3 files changed

+1283
-12
lines changed

3 files changed

+1283
-12
lines changed

src/server/routes/api/document/crossref/works.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,7 @@ const ID_TYPE = Object.freeze({
1919
* @returns
2020
*/
2121
const match = ( paperId, IdType, hits ) => {
22-
const orderByCreation = works => {
23-
const byCreated = ( a, b ) => b.created.timestamp - a.created.timestamp;
24-
25-
let ordered = works;
26-
const top = _.head( works );
27-
if( top ) ordered = works.filter( h => h.score === top.score );
28-
return ordered.sort( byCreated );
29-
};
30-
22+
const byCreated = ( a, b ) => b.created.timestamp - a.created.timestamp;
3123
const sanitize = raw => {
3224
const trimmed = _.trim( raw , ' .');
3325
const lower = _.toLower( trimmed );
@@ -56,9 +48,9 @@ const match = ( paperId, IdType, hits ) => {
5648

5749
// Filter hits based on match to title (partial), DOI (exact
5850
const matches = hits.filter( workMatchesPaperId );
59-
// Order based on score, then created date
60-
const ordered = orderByCreation( matches );
61-
return _.head( ordered );
51+
// Order by created date
52+
matches.sort( byCreated );
53+
return _.head( matches );
6254
};
6355

6456
/**

0 commit comments

Comments
 (0)