aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-query-builder.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-03-11 08:40:13 +0100
committerChocobozzz <me@florianbigard.com>2020-03-11 15:02:20 +0100
commitfab6746354f9d9cb65c35d8bd9352c4b773b4c69 (patch)
treec4465558a82821cd373cb1f23d0bb9e8d158ed68 /server/models/video/video-query-builder.ts
parentcd7ec86f5c621f3ad01753e81fc67358db6e7df6 (diff)
downloadPeerTube-fab6746354f9d9cb65c35d8bd9352c4b773b4c69.tar.gz
PeerTube-fab6746354f9d9cb65c35d8bd9352c4b773b4c69.tar.zst
PeerTube-fab6746354f9d9cb65c35d8bd9352c4b773b4c69.zip
Fix sitemap endpoint
Diffstat (limited to 'server/models/video/video-query-builder.ts')
-rw-r--r--server/models/video/video-query-builder.ts20
1 files changed, 14 insertions, 6 deletions
diff --git a/server/models/video/video-query-builder.ts b/server/models/video/video-query-builder.ts
index 61f628c06..655abf198 100644
--- a/server/models/video/video-query-builder.ts
+++ b/server/models/video/video-query-builder.ts
@@ -3,6 +3,7 @@ import { buildDirectionAndField, createSafeIn } from '@server/models/utils'
3import { Model } from 'sequelize-typescript' 3import { Model } from 'sequelize-typescript'
4import { MUserAccountId, MUserId } from '@server/typings/models' 4import { MUserAccountId, MUserId } from '@server/typings/models'
5import validator from 'validator' 5import validator from 'validator'
6import { exists } from '@server/helpers/custom-validators/misc'
6 7
7export type BuildVideosQueryOptions = { 8export type BuildVideosQueryOptions = {
8 attributes?: string[] 9 attributes?: string[]
@@ -312,14 +313,21 @@ function buildListQuery (model: typeof Model, options: BuildVideosQueryOptions)
312 let suffix = '' 313 let suffix = ''
313 let order = '' 314 let order = ''
314 if (options.isCount !== true) { 315 if (options.isCount !== true) {
315 const count = parseInt(options.count + '', 10)
316 const start = parseInt(options.start + '', 10)
317 316
318 order = buildOrder(model, options.sort) 317 if (exists(options.sort)) {
318 order = buildOrder(model, options.sort)
319 suffix += `${order} `
320 }
321
322 if (exists(options.count)) {
323 const count = parseInt(options.count + '', 10)
324 suffix += `LIMIT ${count} `
325 }
319 326
320 suffix = order + ' ' + 327 if (exists(options.start)) {
321 'LIMIT ' + count + ' ' + 328 const start = parseInt(options.start + '', 10)
322 'OFFSET ' + start 329 suffix += `OFFSET ${start} `
330 }
323 } 331 }
324 332
325 const cteString = cte.length !== 0 333 const cteString = cte.length !== 0