Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(backend): Use OFFSET instead of SKIP when using LIMIT #11379

Merged
merged 2 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading