From 9a4a9b6c4e193739d542f73ee85cd305067f2aea Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 13 Jun 2018 17:43:30 +0200 Subject: [PATCH] Fix offset/limit on some SQL queries :facepalm: --- server/models/account/account-video-rate.ts | 4 ++-- server/models/video/video-comment.ts | 8 ++++---- server/models/video/video-share.ts | 4 ++-- server/tests/api/server/handle-down.ts | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/server/models/account/account-video-rate.ts b/server/models/account/account-video-rate.ts index 508ab814f..9c19ec748 100644 --- a/server/models/account/account-video-rate.ts +++ b/server/models/account/account-video-rate.ts @@ -70,8 +70,8 @@ export class AccountVideoRateModel extends Model { static listAndCountAccountUrlsByVideoId (rateType: VideoRateType, videoId: number, start: number, count: number, t?: Transaction) { const query = { - start, - count, + offset: start, + limit: count, where: { videoId, type: rateType diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts index 353fb1a0e..86766a5d1 100644 --- a/server/models/video/video-comment.ts +++ b/server/models/video/video-comment.ts @@ -329,8 +329,8 @@ export class VideoCommentModel extends Model { static listAndCountByVideoId (videoId: number, start: number, count: number, t?: Sequelize.Transaction, order: 'ASC' | 'DESC' = 'ASC') { const query = { order: [ [ 'createdAt', order ] ], - start, - count, + offset: start, + limit: count, where: { videoId }, @@ -343,8 +343,8 @@ export class VideoCommentModel extends Model { static listForFeed (start: number, count: number, videoId?: number) { const query = { order: [ [ 'createdAt', 'DESC' ] ], - start, - count, + offset: start, + limit: count, where: {}, include: [ { diff --git a/server/models/video/video-share.ts b/server/models/video/video-share.ts index 15dba3f7d..fa9a70d50 100644 --- a/server/models/video/video-share.ts +++ b/server/models/video/video-share.ts @@ -190,8 +190,8 @@ export class VideoShareModel extends Model { static listAndCountByVideoId (videoId: number, start: number, count: number, t?: Sequelize.Transaction) { const query = { - start, - count, + offset: start, + limit: count, where: { videoId }, diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts index 55705caca..69609b4fc 100644 --- a/server/tests/api/server/handle-down.ts +++ b/server/tests/api/server/handle-down.ts @@ -138,7 +138,7 @@ describe('Test handle downs', function () { await waitJobs(servers[0]) // Wait scheduler - await wait(3000) + await wait(11000) const res = await getFollowersListPaginationAndSort(servers[0].url, 0, 1, 'createdAt') expect(res.body.data).to.be.an('array')