mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-07 18:01:42 +00:00
Compare commits
3 commits
1f7be58124
...
9bf8d7de11
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9bf8d7de11 | ||
|
|
6634ce8fd4 | ||
|
|
9d4303ef7b |
2 changed files with 19 additions and 17 deletions
|
|
@ -52,9 +52,7 @@ class FantLab {
|
||||||
return []
|
return []
|
||||||
})
|
})
|
||||||
|
|
||||||
return Promise.all(items.map(async (item) => await this.getWork(item, timeout))).then((resArray) => {
|
return Promise.all(items.map(async (item) => await this.getWork(item, timeout))).then((resArray) => resArray.filter(Boolean))
|
||||||
return resArray.filter((res) => res)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -83,6 +81,10 @@ class FantLab {
|
||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (!bookData) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return this.cleanBookData(bookData, timeout)
|
return this.cleanBookData(bookData, timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -251,6 +251,15 @@ module.exports = {
|
||||||
*/
|
*/
|
||||||
getOrder(sortBy, sortDesc, collapseseries) {
|
getOrder(sortBy, sortDesc, collapseseries) {
|
||||||
const dir = sortDesc ? 'DESC' : 'ASC'
|
const dir = sortDesc ? 'DESC' : 'ASC'
|
||||||
|
|
||||||
|
const getTitleOrder = () => {
|
||||||
|
if (global.ServerSettings.sortingIgnorePrefix) {
|
||||||
|
return [Sequelize.literal('`libraryItem`.`titleIgnorePrefix` COLLATE NOCASE'), dir]
|
||||||
|
} else {
|
||||||
|
return [Sequelize.literal('`libraryItem`.`title` COLLATE NOCASE'), dir]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (sortBy === 'addedAt') {
|
if (sortBy === 'addedAt') {
|
||||||
return [[Sequelize.literal('libraryItem.createdAt'), dir]]
|
return [[Sequelize.literal('libraryItem.createdAt'), dir]]
|
||||||
} else if (sortBy === 'size') {
|
} else if (sortBy === 'size') {
|
||||||
|
|
@ -264,25 +273,16 @@ module.exports = {
|
||||||
} else if (sortBy === 'media.metadata.publishedYear') {
|
} else if (sortBy === 'media.metadata.publishedYear') {
|
||||||
return [[Sequelize.literal(`CAST(\`book\`.\`publishedYear\` AS INTEGER)`), dir]]
|
return [[Sequelize.literal(`CAST(\`book\`.\`publishedYear\` AS INTEGER)`), dir]]
|
||||||
} else if (sortBy === 'media.metadata.authorNameLF') {
|
} else if (sortBy === 'media.metadata.authorNameLF') {
|
||||||
return [
|
// Sort by author name last first, secondary sort by title
|
||||||
[Sequelize.literal('`libraryItem`.`authorNamesLastFirst` COLLATE NOCASE'), dir],
|
return [[Sequelize.literal('`libraryItem`.`authorNamesLastFirst` COLLATE NOCASE'), dir], getTitleOrder()]
|
||||||
[Sequelize.literal('`libraryItem`.`title` COLLATE NOCASE'), dir]
|
|
||||||
]
|
|
||||||
} else if (sortBy === 'media.metadata.authorName') {
|
} else if (sortBy === 'media.metadata.authorName') {
|
||||||
return [
|
// Sort by author name first last, secondary sort by title
|
||||||
[Sequelize.literal('`libraryItem`.`authorNamesFirstLast` COLLATE NOCASE'), dir],
|
return [[Sequelize.literal('`libraryItem`.`authorNamesFirstLast` COLLATE NOCASE'), dir], getTitleOrder()]
|
||||||
[Sequelize.literal('`libraryItem`.`title` COLLATE NOCASE'), dir]
|
|
||||||
]
|
|
||||||
} else if (sortBy === 'media.metadata.title') {
|
} else if (sortBy === 'media.metadata.title') {
|
||||||
if (collapseseries) {
|
if (collapseseries) {
|
||||||
return [[Sequelize.literal('display_title COLLATE NOCASE'), dir]]
|
return [[Sequelize.literal('display_title COLLATE NOCASE'), dir]]
|
||||||
}
|
}
|
||||||
|
return [getTitleOrder()]
|
||||||
if (global.ServerSettings.sortingIgnorePrefix) {
|
|
||||||
return [[Sequelize.literal('`libraryItem`.`titleIgnorePrefix` COLLATE NOCASE'), dir]]
|
|
||||||
} else {
|
|
||||||
return [[Sequelize.literal('`libraryItem`.`title` COLLATE NOCASE'), dir]]
|
|
||||||
}
|
|
||||||
} else if (sortBy === 'sequence') {
|
} else if (sortBy === 'sequence') {
|
||||||
const nullDir = sortDesc ? 'DESC NULLS FIRST' : 'ASC NULLS LAST'
|
const nullDir = sortDesc ? 'DESC NULLS FIRST' : 'ASC NULLS LAST'
|
||||||
return [[Sequelize.literal(`CAST(\`series.bookSeries.sequence\` AS FLOAT) ${nullDir}`)]]
|
return [[Sequelize.literal(`CAST(\`series.bookSeries.sequence\` AS FLOAT) ${nullDir}`)]]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue