perf(backend): use limit() instead of take()
This commit is contained in:
parent
b056e8f5eb
commit
081a14d6f3
71 changed files with 76 additions and 75 deletions
|
|
@ -48,7 +48,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
.andWhere('clip.isPublic = true');
|
||||
|
||||
const clips = await query
|
||||
.take(ps.limit)
|
||||
.limit(ps.limit)
|
||||
.getMany();
|
||||
|
||||
return await this.clipEntityService.packMany(clips, me);
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
.innerJoinAndSelect('following.follower', 'follower');
|
||||
|
||||
const followings = await query
|
||||
.take(ps.limit)
|
||||
.limit(ps.limit)
|
||||
.getMany();
|
||||
|
||||
return await this.followingEntityService.packMany(followings, me, { populateFollower: true });
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
.innerJoinAndSelect('following.followee', 'followee');
|
||||
|
||||
const followings = await query
|
||||
.take(ps.limit)
|
||||
.limit(ps.limit)
|
||||
.getMany();
|
||||
|
||||
return await this.followingEntityService.packMany(followings, me, { populateFollowee: true });
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
.andWhere('post.userId = :userId', { userId: ps.userId });
|
||||
|
||||
const posts = await query
|
||||
.take(ps.limit)
|
||||
.limit(ps.limit)
|
||||
.getMany();
|
||||
|
||||
return await this.galleryPostEntityService.packMany(posts, me);
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
|
||||
//#endregion
|
||||
|
||||
const timeline = await query.take(ps.limit).getMany();
|
||||
const timeline = await query.limit(ps.limit).getMany();
|
||||
|
||||
return await this.noteEntityService.packMany(timeline, me);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
.andWhere('page.visibility = \'public\'');
|
||||
|
||||
const pages = await query
|
||||
.take(ps.limit)
|
||||
.limit(ps.limit)
|
||||
.getMany();
|
||||
|
||||
return await this.pageEntityService.packMany(pages);
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
this.queryService.generateVisibilityQuery(query, me);
|
||||
|
||||
const reactions = await query
|
||||
.take(ps.limit)
|
||||
.limit(ps.limit)
|
||||
.getMany();
|
||||
|
||||
return await Promise.all(reactions.map(reaction => this.noteReactionEntityService.pack(reaction, me, { withNote: true })));
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
|
||||
query.setParameters(followingQuery.getParameters());
|
||||
|
||||
const users = await query.take(ps.limit).skip(ps.offset).getMany();
|
||||
const users = await query.limit(ps.limit).skip(ps.offset).getMany();
|
||||
|
||||
return await this.userEntityService.packMany(users, me, { detail: true });
|
||||
});
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
|
||||
users = await query
|
||||
.orderBy('user.usernameLower', 'ASC')
|
||||
.take(ps.limit)
|
||||
.limit(ps.limit)
|
||||
.getMany();
|
||||
|
||||
if (users.length < ps.limit) {
|
||||
|
|
@ -110,7 +110,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
|
||||
const otherUsers = await otherQuery
|
||||
.orderBy('user.updatedAt', 'DESC')
|
||||
.take(ps.limit - users.length)
|
||||
.limit(ps.limit - users.length)
|
||||
.getMany();
|
||||
|
||||
users = users.concat(otherUsers);
|
||||
|
|
@ -122,7 +122,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
|
||||
users = await query
|
||||
.orderBy('user.updatedAt', 'DESC')
|
||||
.take(ps.limit - users.length)
|
||||
.limit(ps.limit - users.length)
|
||||
.getMany();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
|
||||
users = await usernameQuery
|
||||
.orderBy('user.updatedAt', 'DESC', 'NULLS LAST')
|
||||
.take(ps.limit)
|
||||
.limit(ps.limit)
|
||||
.skip(ps.offset)
|
||||
.getMany();
|
||||
} else {
|
||||
|
|
@ -100,7 +100,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
|
||||
users = await nameQuery
|
||||
.orderBy('user.updatedAt', 'DESC', 'NULLS LAST')
|
||||
.take(ps.limit)
|
||||
.limit(ps.limit)
|
||||
.skip(ps.offset)
|
||||
.getMany();
|
||||
|
||||
|
|
@ -126,7 +126,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
|
||||
users = users.concat(await query
|
||||
.orderBy('user.updatedAt', 'DESC', 'NULLS LAST')
|
||||
.take(ps.limit)
|
||||
.limit(ps.limit)
|
||||
.skip(ps.offset)
|
||||
.getMany(),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue