From c1a19ff900b30fb318b3eb8aea96b80d7b48c5ef Mon Sep 17 00:00:00 2001 From: tamaina Date: Tue, 25 Jul 2023 19:21:50 +0900 Subject: [PATCH] fix(backend): Use OFFSET instead of SKIP when using LIMIT (#11379) * fix(backend): Use OFFSET instead of SKIP when using LIMIT * update CHANGELOG.md --- CHANGELOG.md | 2 +- .../backend/src/server/api/endpoints/admin/invite/list.ts | 2 +- .../backend/src/server/api/endpoints/admin/show-users.ts | 2 +- .../src/server/api/endpoints/federation/instances.ts | 2 +- .../backend/src/server/api/endpoints/hashtags/search.ts | 2 +- .../src/server/api/endpoints/notes/polls/recommendation.ts | 2 +- packages/backend/src/server/api/endpoints/users.ts | 2 +- .../src/server/api/endpoints/users/recommendation.ts | 2 +- packages/backend/src/server/api/endpoints/users/search.ts | 6 +++--- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00ca2982c..778438729 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,7 @@ - リストTLで、ユーザーが追加・削除されてもTLを初期化しないように ### Server -- +- Fix: APIのオフセットが壊れていたせいで「もっと見る」でもっと見れない問題を修正 ## 13.14.1 diff --git a/packages/backend/src/server/api/endpoints/admin/invite/list.ts b/packages/backend/src/server/api/endpoints/admin/invite/list.ts index 5d7a7f632..d8bf6e286 100644 --- a/packages/backend/src/server/api/endpoints/admin/invite/list.ts +++ b/packages/backend/src/server/api/endpoints/admin/invite/list.ts @@ -60,7 +60,7 @@ export default class extends Endpoint { } query.limit(ps.limit); - query.skip(ps.offset); + query.offset(ps.offset); const tickets = await query.getMany(); diff --git a/packages/backend/src/server/api/endpoints/admin/show-users.ts b/packages/backend/src/server/api/endpoints/admin/show-users.ts index 0a150d1df..2ae5bc3de 100644 --- a/packages/backend/src/server/api/endpoints/admin/show-users.ts +++ b/packages/backend/src/server/api/endpoints/admin/show-users.ts @@ -105,7 +105,7 @@ export default class extends Endpoint { } query.limit(ps.limit); - query.skip(ps.offset); + query.offset(ps.offset); const users = await query.getMany(); diff --git a/packages/backend/src/server/api/endpoints/federation/instances.ts b/packages/backend/src/server/api/endpoints/federation/instances.ts index ddf1a178b..b140321f4 100644 --- a/packages/backend/src/server/api/endpoints/federation/instances.ts +++ b/packages/backend/src/server/api/endpoints/federation/instances.ts @@ -126,7 +126,7 @@ export default class extends Endpoint { query.andWhere('instance.host like :host', { host: '%' + sqlLikeEscape(ps.host.toLowerCase()) + '%' }); } - const instances = await query.limit(ps.limit).skip(ps.offset).getMany(); + const instances = await query.limit(ps.limit).offset(ps.offset).getMany(); return await this.instanceEntityService.packMany(instances); }); diff --git a/packages/backend/src/server/api/endpoints/hashtags/search.ts b/packages/backend/src/server/api/endpoints/hashtags/search.ts index e2e00def7..81a790316 100644 --- a/packages/backend/src/server/api/endpoints/hashtags/search.ts +++ b/packages/backend/src/server/api/endpoints/hashtags/search.ts @@ -42,7 +42,7 @@ export default class extends Endpoint { .orderBy('tag.count', 'DESC') .groupBy('tag.id') .limit(ps.limit) - .skip(ps.offset) + .offset(ps.offset) .getMany(); return hashtags.map(tag => tag.name); diff --git a/packages/backend/src/server/api/endpoints/notes/polls/recommendation.ts b/packages/backend/src/server/api/endpoints/notes/polls/recommendation.ts index 0b4ccdcf2..889f64464 100644 --- a/packages/backend/src/server/api/endpoints/notes/polls/recommendation.ts +++ b/packages/backend/src/server/api/endpoints/notes/polls/recommendation.ts @@ -83,7 +83,7 @@ export default class extends Endpoint { const polls = await query .orderBy('poll.noteId', 'DESC') .limit(ps.limit) - .skip(ps.offset) + .offset(ps.offset) .getMany(); if (polls.length === 0) return []; diff --git a/packages/backend/src/server/api/endpoints/users.ts b/packages/backend/src/server/api/endpoints/users.ts index 2582932e3..47d0a8155 100644 --- a/packages/backend/src/server/api/endpoints/users.ts +++ b/packages/backend/src/server/api/endpoints/users.ts @@ -81,7 +81,7 @@ export default class extends Endpoint { if (me) this.queryService.generateBlockQueryForUsers(query, me); query.limit(ps.limit); - query.skip(ps.offset); + query.offset(ps.offset); const users = await query.getMany(); diff --git a/packages/backend/src/server/api/endpoints/users/recommendation.ts b/packages/backend/src/server/api/endpoints/users/recommendation.ts index d39657059..eebc5d14d 100644 --- a/packages/backend/src/server/api/endpoints/users/recommendation.ts +++ b/packages/backend/src/server/api/endpoints/users/recommendation.ts @@ -70,7 +70,7 @@ export default class extends Endpoint { query.setParameters(followingQuery.getParameters()); - const users = await query.limit(ps.limit).skip(ps.offset).getMany(); + const users = await query.limit(ps.limit).offset(ps.offset).getMany(); return await this.userEntityService.packMany(users, me, { detail: true }); }); diff --git a/packages/backend/src/server/api/endpoints/users/search.ts b/packages/backend/src/server/api/endpoints/users/search.ts index 1180de361..836218ccd 100644 --- a/packages/backend/src/server/api/endpoints/users/search.ts +++ b/packages/backend/src/server/api/endpoints/users/search.ts @@ -75,7 +75,7 @@ export default class extends Endpoint { users = await usernameQuery .orderBy('user.updatedAt', 'DESC', 'NULLS LAST') .limit(ps.limit) - .skip(ps.offset) + .offset(ps.offset) .getMany(); } else { const nameQuery = this.usersRepository.createQueryBuilder('user') @@ -102,7 +102,7 @@ export default class extends Endpoint { users = await nameQuery .orderBy('user.updatedAt', 'DESC', 'NULLS LAST') .limit(ps.limit) - .skip(ps.offset) + .offset(ps.offset) .getMany(); if (users.length < ps.limit) { @@ -128,7 +128,7 @@ export default class extends Endpoint { users = users.concat(await query .orderBy('user.updatedAt', 'DESC', 'NULLS LAST') .limit(ps.limit) - .skip(ps.offset) + .offset(ps.offset) .getMany(), ); }