mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-08 00:08:14 +01:00
Refactor diff declarations in title candidate sorting
This commit is contained in:
parent
047e7a72f2
commit
5a3d450482
@ -201,11 +201,11 @@ class BookFinder {
|
|||||||
var candidates = [...this.candidates]
|
var candidates = [...this.candidates]
|
||||||
candidates.sort((a, b) => {
|
candidates.sort((a, b) => {
|
||||||
// Candidates that include the author are likely low quality
|
// 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
|
if (includesAuthorDiff) return includesAuthorDiff
|
||||||
// Candidates that include only digits are also likely low quality
|
// Candidates that include only digits are also likely low quality
|
||||||
const onlyDigits = /^\d+$/
|
const onlyDigits = /^\d+$/
|
||||||
const includesOnlyDigitsDiff = !onlyDigits.test(b) - !onlyDigits.test(a)
|
const includesOnlyDigitsDiff = onlyDigits.test(a) - onlyDigits.test(b)
|
||||||
if (includesOnlyDigitsDiff) return includesOnlyDigitsDiff
|
if (includesOnlyDigitsDiff) return includesOnlyDigitsDiff
|
||||||
// transformed candidates receive higher priority
|
// transformed candidates receive higher priority
|
||||||
const priorityDiff = this.priorities[a] - this.priorities[b]
|
const priorityDiff = this.priorities[a] - this.priorities[b]
|
||||||
|
Loading…
Reference in New Issue
Block a user