Skip to content

Commit

Permalink
fix(backend): Use OFFSET instead of SKIP when using LIMIT (#11379)
Browse files Browse the repository at this point in the history
* fix(backend): Use OFFSET instead of SKIP when using LIMIT

* update CHANGELOG.md
  • Loading branch information
tamaina authored Jul 25, 2023
1 parent ac6a8ed commit c1a19ff
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
- リストTLで、ユーザーが追加・削除されてもTLを初期化しないように

### Server
-
- Fix: APIのオフセットが壊れていたせいで「もっと見る」でもっと見れない問題を修正

## 13.14.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
}

query.limit(ps.limit);
query.skip(ps.offset);
query.offset(ps.offset);

const tickets = await query.getMany();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
}

query.limit(ps.limit);
query.skip(ps.offset);
query.offset(ps.offset);

const users = await query.getMany();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.orderBy('tag.count', 'DESC')
.groupBy('tag.id')
.limit(ps.limit)
.skip(ps.offset)
.offset(ps.offset)
.getMany();

return hashtags.map(tag => tag.name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
const polls = await query
.orderBy('poll.noteId', 'DESC')
.limit(ps.limit)
.skip(ps.offset)
.offset(ps.offset)
.getMany();

if (polls.length === 0) return [];
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/server/api/endpoints/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
if (me) this.queryService.generateBlockQueryForUsers(query, me);

query.limit(ps.limit);
query.skip(ps.offset);
query.offset(ps.offset);

const users = await query.getMany();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {

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 });
});
Expand Down
6 changes: 3 additions & 3 deletions packages/backend/src/server/api/endpoints/users/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
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')
Expand All @@ -102,7 +102,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
users = await nameQuery
.orderBy('user.updatedAt', 'DESC', 'NULLS LAST')
.limit(ps.limit)
.skip(ps.offset)
.offset(ps.offset)
.getMany();

if (users.length < ps.limit) {
Expand All @@ -128,7 +128,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
users = users.concat(await query
.orderBy('user.updatedAt', 'DESC', 'NULLS LAST')
.limit(ps.limit)
.skip(ps.offset)
.offset(ps.offset)
.getMany(),
);
}
Expand Down

0 comments on commit c1a19ff

Please sign in to comment.