Remove series search api endpoint, update authors and series to load from db

This commit is contained in:
advplyr
2023-09-03 10:49:02 -05:00
parent 7567e91878
commit 9123dcb365
10 changed files with 79 additions and 53 deletions

View File

@@ -1,4 +1,4 @@
const { DataTypes, Model } = require('sequelize')
const { DataTypes, Model, literal } = require('sequelize')
const oldAuthor = require('../objects/entities/Author')
@@ -86,7 +86,7 @@ class Author extends Model {
/**
* Get oldAuthor by id
* @param {string} authorId
* @returns {oldAuthor}
* @returns {Promise<oldAuthor>}
*/
static async getOldById(authorId) {
const author = await this.findByPk(authorId)
@@ -103,6 +103,26 @@ class Author extends Model {
return (await this.count({ where: { id: authorId } })) > 0
}
/**
* Get old author by name and libraryId. name case insensitive
* TODO: Look for authors ignoring punctuation
*
* @param {string} authorName
* @param {string} libraryId
* @returns {Promise<oldAuthor>}
*/
static async getOldByNameAndLibrary(authorName, libraryId) {
const author = (await this.findOne({
where: [
literal(`name = '${authorName}' COLLATE NOCASE`),
{
libraryId
}
]
}))?.getOldAuthor()
return author
}
/**
* Initialize model
* @param {import('../Database').sequelize} sequelize