Fix sitemap endpoint
This commit is contained in:
parent
cd7ec86f5c
commit
fab6746354
|
@ -3,6 +3,7 @@ import { buildDirectionAndField, createSafeIn } from '@server/models/utils'
|
||||||
import { Model } from 'sequelize-typescript'
|
import { Model } from 'sequelize-typescript'
|
||||||
import { MUserAccountId, MUserId } from '@server/typings/models'
|
import { MUserAccountId, MUserId } from '@server/typings/models'
|
||||||
import validator from 'validator'
|
import validator from 'validator'
|
||||||
|
import { exists } from '@server/helpers/custom-validators/misc'
|
||||||
|
|
||||||
export type BuildVideosQueryOptions = {
|
export type BuildVideosQueryOptions = {
|
||||||
attributes?: string[]
|
attributes?: string[]
|
||||||
|
@ -312,14 +313,21 @@ function buildListQuery (model: typeof Model, options: BuildVideosQueryOptions)
|
||||||
let suffix = ''
|
let suffix = ''
|
||||||
let order = ''
|
let order = ''
|
||||||
if (options.isCount !== true) {
|
if (options.isCount !== true) {
|
||||||
const count = parseInt(options.count + '', 10)
|
|
||||||
const start = parseInt(options.start + '', 10)
|
|
||||||
|
|
||||||
order = buildOrder(model, options.sort)
|
if (exists(options.sort)) {
|
||||||
|
order = buildOrder(model, options.sort)
|
||||||
|
suffix += `${order} `
|
||||||
|
}
|
||||||
|
|
||||||
suffix = order + ' ' +
|
if (exists(options.count)) {
|
||||||
'LIMIT ' + count + ' ' +
|
const count = parseInt(options.count + '', 10)
|
||||||
'OFFSET ' + start
|
suffix += `LIMIT ${count} `
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exists(options.start)) {
|
||||||
|
const start = parseInt(options.start + '', 10)
|
||||||
|
suffix += `OFFSET ${start} `
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const cteString = cte.length !== 0
|
const cteString = cte.length !== 0
|
||||||
|
|
Loading…
Reference in New Issue