From 5a3d450482b31c31f0d60c049f499fb9d871c829 Mon Sep 17 00:00:00 2001 From: mikiher Date: Sun, 5 Nov 2023 15:13:42 +0000 Subject: [PATCH] Refactor diff declarations in title candidate sorting --- server/finders/BookFinder.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/finders/BookFinder.js b/server/finders/BookFinder.js index 212c588a..e3a84be0 100644 --- a/server/finders/BookFinder.js +++ b/server/finders/BookFinder.js @@ -201,11 +201,11 @@ class BookFinder { var candidates = [...this.candidates] candidates.sort((a, b) => { // Candidates that include the author are likely low quality - const includesAuthorDiff = !b.includes(this.cleanAuthor) - !a.includes(this.cleanAuthor) + const includesAuthorDiff = a.includes(this.cleanAuthor) - b.includes(this.cleanAuthor) if (includesAuthorDiff) return includesAuthorDiff // Candidates that include only digits are also likely low quality const onlyDigits = /^\d+$/ - const includesOnlyDigitsDiff = !onlyDigits.test(b) - !onlyDigits.test(a) + const includesOnlyDigitsDiff = onlyDigits.test(a) - onlyDigits.test(b) if (includesOnlyDigitsDiff) return includesOnlyDigitsDiff // transformed candidates receive higher priority const priorityDiff = this.priorities[a] - this.priorities[b]