perf(backend): use limit() instead of take()

This commit is contained in:
syuilo 2023-07-08 16:53:07 +09:00
parent b056e8f5eb
commit 081a14d6f3
71 changed files with 76 additions and 75 deletions

View file

@ -34,6 +34,7 @@
- JSON.parse の回数を削減することで、ストリーミングのパフォーマンスを向上しました - JSON.parse の回数を削減することで、ストリーミングのパフォーマンスを向上しました
- nsfwjs のモデルロードを排他することで、重複ロードによってメモリ使用量が増加しないように - nsfwjs のモデルロードを排他することで、重複ロードによってメモリ使用量が増加しないように
- 連合の配送ジョブのパフォーマンスを向上ロック機構の見直し、Redisキャッシュの活用 - 連合の配送ジョブのパフォーマンスを向上ロック機構の見直し、Redisキャッシュの活用
- 全体的なDBクエリのパフォーマンスを向上
## 13.13.2 ## 13.13.2

View file

@ -174,7 +174,7 @@ export class SearchService {
if (me) this.queryService.generateMutedUserQuery(query, me); if (me) this.queryService.generateMutedUserQuery(query, me);
if (me) this.queryService.generateBlockedUserQuery(query, me); if (me) this.queryService.generateBlockedUserQuery(query, me);
return await query.take(pagination.limit).getMany(); return await query.limit(pagination.limit).getMany();
} }
} }
} }

View file

@ -369,7 +369,7 @@ export class ActivityPubServerService {
})) }))
.andWhere('note.localOnly = FALSE'); .andWhere('note.localOnly = FALSE');
const notes = await query.take(limit).getMany(); const notes = await query.limit(limit).getMany();
if (sinceId) notes.reverse(); if (sinceId) notes.reverse();

View file

@ -115,7 +115,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
case 'remote': query.andWhere('report.targetUserHost IS NOT NULL'); break; case 'remote': query.andWhere('report.targetUserHost IS NOT NULL'); break;
} }
const reports = await query.take(ps.limit).getMany(); const reports = await query.limit(ps.limit).getMany();
return await this.abuseUserReportEntityService.packMany(reports); return await this.abuseUserReportEntityService.packMany(reports);
}); });

View file

@ -32,7 +32,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
) { ) {
super(meta, paramDef, async (ps, me) => { super(meta, paramDef, async (ps, me) => {
const query = this.queryService.makePaginationQuery(this.adsRepository.createQueryBuilder('ad'), ps.sinceId, ps.untilId); const query = this.queryService.makePaginationQuery(this.adsRepository.createQueryBuilder('ad'), ps.sinceId, ps.untilId);
const ads = await query.take(ps.limit).getMany(); const ads = await query.limit(ps.limit).getMany();
return ads; return ads;
}); });

View file

@ -80,7 +80,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
super(meta, paramDef, async (ps, me) => { super(meta, paramDef, async (ps, me) => {
const query = this.queryService.makePaginationQuery(this.announcementsRepository.createQueryBuilder('announcement'), ps.sinceId, ps.untilId); const query = this.queryService.makePaginationQuery(this.announcementsRepository.createQueryBuilder('announcement'), ps.sinceId, ps.untilId);
const announcements = await query.take(ps.limit).getMany(); const announcements = await query.limit(ps.limit).getMany();
const reads = new Map<Announcement, number>(); const reads = new Map<Announcement, number>();

View file

@ -76,7 +76,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
} }
} }
const files = await query.take(ps.limit).getMany(); const files = await query.limit(ps.limit).getMany();
return await this.driveFileEntityService.packMany(files, { detail: true, withUser: true, self: true }); return await this.driveFileEntityService.packMany(files, { detail: true, withUser: true, self: true });
}); });

View file

@ -98,7 +98,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
const emojis = await q const emojis = await q
.orderBy('emoji.id', 'DESC') .orderBy('emoji.id', 'DESC')
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return this.emojiEntityService.packDetailedMany(emojis); return this.emojiEntityService.packDetailedMany(emojis);

View file

@ -84,7 +84,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
if (ps.query) { if (ps.query) {
//q.andWhere('emoji.name ILIKE :q', { q: `%${ sqlLikeEscape(ps.query) }%` }); //q.andWhere('emoji.name ILIKE :q', { q: `%${ sqlLikeEscape(ps.query) }%` });
//const emojis = await q.take(ps.limit).getMany(); //const emojis = await q.limit(ps.limit).getMany();
emojis = await q.getMany(); emojis = await q.getMany();
const queryarry = ps.query.match(/\:([a-z0-9_]*)\:/g); const queryarry = ps.query.match(/\:([a-z0-9_]*)\:/g);
@ -101,7 +101,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
} }
emojis.splice(ps.limit + 1); emojis.splice(ps.limit + 1);
} else { } else {
emojis = await q.take(ps.limit).getMany(); emojis = await q.limit(ps.limit).getMany();
} }
return this.emojiEntityService.packDetailedMany(emojis); return this.emojiEntityService.packDetailedMany(emojis);

View file

@ -64,7 +64,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.innerJoinAndSelect('assign.user', 'user'); .innerJoinAndSelect('assign.user', 'user');
const assigns = await query const assigns = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return await Promise.all(assigns.map(async assign => ({ return await Promise.all(assigns.map(async assign => ({

View file

@ -74,7 +74,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
super(meta, paramDef, async (ps, me) => { super(meta, paramDef, async (ps, me) => {
const query = this.queryService.makePaginationQuery(this.moderationLogsRepository.createQueryBuilder('report'), ps.sinceId, ps.untilId); const query = this.queryService.makePaginationQuery(this.moderationLogsRepository.createQueryBuilder('report'), ps.sinceId, ps.untilId);
const reports = await query.take(ps.limit).getMany(); const reports = await query.limit(ps.limit).getMany();
return await this.moderationLogEntityService.packMany(reports); return await this.moderationLogEntityService.packMany(reports);
}); });

View file

@ -104,7 +104,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
default: query.orderBy('user.id', 'ASC'); break; default: query.orderBy('user.id', 'ASC'); break;
} }
query.take(ps.limit); query.limit(ps.limit);
query.skip(ps.offset); query.skip(ps.offset);
const users = await query.getMany(); const users = await query.getMany();

View file

@ -79,7 +79,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
super(meta, paramDef, async (ps, me) => { super(meta, paramDef, async (ps, me) => {
const query = this.queryService.makePaginationQuery(this.announcementsRepository.createQueryBuilder('announcement'), ps.sinceId, ps.untilId); const query = this.queryService.makePaginationQuery(this.announcementsRepository.createQueryBuilder('announcement'), ps.sinceId, ps.untilId);
const announcements = await query.take(ps.limit).getMany(); const announcements = await query.limit(ps.limit).getMany();
if (me) { if (me) {
const reads = (await this.announcementReadsRepository.findBy({ const reads = (await this.announcementReadsRepository.findBy({

View file

@ -48,7 +48,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.andWhere('blocking.blockerId = :meId', { meId: me.id }); .andWhere('blocking.blockerId = :meId', { meId: me.id });
const blockings = await query const blockings = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return await this.blockingEntityService.packMany(blockings, me); return await this.blockingEntityService.packMany(blockings, me);

View file

@ -41,7 +41,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.andWhere('channel.isArchived = FALSE') .andWhere('channel.isArchived = FALSE')
.orderBy('channel.lastNotedAt', 'DESC'); .orderBy('channel.lastNotedAt', 'DESC');
const channels = await query.take(10).getMany(); const channels = await query.limit(10).getMany();
return await Promise.all(channels.map(x => this.channelEntityService.pack(x, me))); return await Promise.all(channels.map(x => this.channelEntityService.pack(x, me)));
}); });

View file

@ -48,7 +48,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.andWhere({ followerId: me.id }); .andWhere({ followerId: me.id });
const followings = await query const followings = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return await Promise.all(followings.map(x => this.channelEntityService.pack(x.followeeId, me))); return await Promise.all(followings.map(x => this.channelEntityService.pack(x.followeeId, me)));

View file

@ -49,7 +49,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.andWhere({ userId: me.id }); .andWhere({ userId: me.id });
const channels = await query const channels = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return await Promise.all(channels.map(x => this.channelEntityService.pack(x, me))); return await Promise.all(channels.map(x => this.channelEntityService.pack(x, me)));

View file

@ -61,7 +61,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
} }
const channels = await query const channels = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return await Promise.all(channels.map(x => this.channelEntityService.pack(x, me))); return await Promise.all(channels.map(x => this.channelEntityService.pack(x, me)));

View file

@ -105,7 +105,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
} }
//#endregion //#endregion
timeline = await query.take(ps.limit).getMany(); timeline = await query.limit(ps.limit).getMany();
} else { } else {
const noteIds = noteIdsRes.map(x => x[1][1]).filter(x => x !== ps.untilId); const noteIds = noteIdsRes.map(x => x[1][1]).filter(x => x !== ps.untilId);

View file

@ -88,7 +88,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
} }
const notes = await query const notes = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return await this.noteEntityService.packMany(notes, me); return await this.noteEntityService.packMany(notes, me);

View file

@ -73,7 +73,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
case '-size': query.orderBy('file.size', 'ASC'); break; case '-size': query.orderBy('file.size', 'ASC'); break;
} }
const files = await query.take(ps.limit).getMany(); const files = await query.limit(ps.limit).getMany();
return await this.driveFileEntityService.packMany(files, { detail: false, self: true }); return await this.driveFileEntityService.packMany(files, { detail: false, self: true });
}); });

View file

@ -54,7 +54,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
query.andWhere('folder.parentId IS NULL'); query.andWhere('folder.parentId IS NULL');
} }
const folders = await query.take(ps.limit).getMany(); const folders = await query.limit(ps.limit).getMany();
return await Promise.all(folders.map(folder => this.driveFolderEntityService.pack(folder))); return await Promise.all(folders.map(folder => this.driveFolderEntityService.pack(folder)));
}); });

View file

@ -56,7 +56,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
} }
} }
const files = await query.take(ps.limit).getMany(); const files = await query.limit(ps.limit).getMany();
return await this.driveFileEntityService.packMany(files, { detail: false, self: true }); return await this.driveFileEntityService.packMany(files, { detail: false, self: true });
}); });

View file

@ -47,7 +47,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.andWhere('following.followeeHost = :host', { host: ps.host }); .andWhere('following.followeeHost = :host', { host: ps.host });
const followings = await query const followings = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return await this.followingEntityService.packMany(followings, me, { populateFollowee: true }); return await this.followingEntityService.packMany(followings, me, { populateFollowee: true });

View file

@ -47,7 +47,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.andWhere('following.followerHost = :host', { host: ps.host }); .andWhere('following.followerHost = :host', { host: ps.host });
const followings = await query const followings = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return await this.followingEntityService.packMany(followings, me, { populateFollowee: true }); return await this.followingEntityService.packMany(followings, me, { populateFollowee: true });

View file

@ -126,7 +126,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
query.andWhere('instance.host like :host', { host: '%' + sqlLikeEscape(ps.host.toLowerCase()) + '%' }); query.andWhere('instance.host like :host', { host: '%' + sqlLikeEscape(ps.host.toLowerCase()) + '%' });
} }
const instances = await query.take(ps.limit).skip(ps.offset).getMany(); const instances = await query.limit(ps.limit).skip(ps.offset).getMany();
return await this.instanceEntityService.packMany(instances); return await this.instanceEntityService.packMany(instances);
}); });

View file

@ -47,7 +47,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.andWhere('user.host = :host', { host: ps.host }); .andWhere('user.host = :host', { host: ps.host });
const users = await query const users = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return await this.userEntityService.packMany(users, me, { detail: true }); return await this.userEntityService.packMany(users, me, { detail: true });

View file

@ -40,7 +40,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.andWhere('flash.likedCount > 0') .andWhere('flash.likedCount > 0')
.orderBy('flash.likedCount', 'DESC'); .orderBy('flash.likedCount', 'DESC');
const flashs = await query.take(10).getMany(); const flashs = await query.limit(10).getMany();
return await this.flashEntityService.packMany(flashs, me); return await this.flashEntityService.packMany(flashs, me);
}); });

View file

@ -59,7 +59,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.leftJoinAndSelect('like.flash', 'flash'); .leftJoinAndSelect('like.flash', 'flash');
const likes = await query const likes = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return this.flashLikeEntityService.packMany(likes, me); return this.flashLikeEntityService.packMany(likes, me);

View file

@ -48,7 +48,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.andWhere('flash.userId = :meId', { meId: me.id }); .andWhere('flash.userId = :meId', { meId: me.id });
const flashs = await query const flashs = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return await this.flashEntityService.packMany(flashs); return await this.flashEntityService.packMany(flashs);

View file

@ -64,7 +64,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.andWhere('request.followeeId = :meId', { meId: me.id }); .andWhere('request.followeeId = :meId', { meId: me.id });
const requests = await query const requests = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return await Promise.all(requests.map(req => this.followRequestEntityService.pack(req))); return await Promise.all(requests.map(req => this.followRequestEntityService.pack(req)));

View file

@ -41,7 +41,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.andWhere('post.likedCount > 0') .andWhere('post.likedCount > 0')
.orderBy('post.likedCount', 'DESC'); .orderBy('post.likedCount', 'DESC');
const posts = await query.take(10).getMany(); const posts = await query.limit(10).getMany();
return await this.galleryPostEntityService.packMany(posts, me); return await this.galleryPostEntityService.packMany(posts, me);
}); });

View file

@ -40,7 +40,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.andWhere('post.likedCount > 0') .andWhere('post.likedCount > 0')
.orderBy('post.likedCount', 'DESC'); .orderBy('post.likedCount', 'DESC');
const posts = await query.take(10).getMany(); const posts = await query.limit(10).getMany();
return await this.galleryPostEntityService.packMany(posts, me); return await this.galleryPostEntityService.packMany(posts, me);
}); });

View file

@ -43,7 +43,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
const query = this.queryService.makePaginationQuery(this.galleryPostsRepository.createQueryBuilder('post'), ps.sinceId, ps.untilId) const query = this.queryService.makePaginationQuery(this.galleryPostsRepository.createQueryBuilder('post'), ps.sinceId, ps.untilId)
.innerJoinAndSelect('post.user', 'user'); .innerJoinAndSelect('post.user', 'user');
const posts = await query.take(ps.limit).getMany(); const posts = await query.limit(ps.limit).getMany();
return await this.galleryPostEntityService.packMany(posts, me); return await this.galleryPostEntityService.packMany(posts, me);
}); });

View file

@ -73,7 +73,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
'tag.attachedRemoteUsersCount', 'tag.attachedRemoteUsersCount',
]); ]);
const tags = await query.take(ps.limit).getMany(); const tags = await query.limit(ps.limit).getMany();
return this.hashtagEntityService.packMany(tags); return this.hashtagEntityService.packMany(tags);
}); });

View file

@ -41,7 +41,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.where('tag.name like :q', { q: sqlLikeEscape(ps.query.toLowerCase()) + '%' }) .where('tag.name like :q', { q: sqlLikeEscape(ps.query.toLowerCase()) + '%' })
.orderBy('tag.count', 'DESC') .orderBy('tag.count', 'DESC')
.groupBy('tag.id') .groupBy('tag.id')
.take(ps.limit) .limit(ps.limit)
.skip(ps.offset) .skip(ps.offset)
.getMany(); .getMany();

View file

@ -68,7 +68,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
case '-updatedAt': query.orderBy('user.updatedAt', 'ASC'); break; case '-updatedAt': query.orderBy('user.updatedAt', 'ASC'); break;
} }
const users = await query.take(ps.limit).getMany(); const users = await query.limit(ps.limit).getMany();
return await this.userEntityService.packMany(users, me, { detail: true }); return await this.userEntityService.packMany(users, me, { detail: true });
}); });

View file

@ -49,7 +49,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.leftJoinAndSelect('favorite.note', 'note'); .leftJoinAndSelect('favorite.note', 'note');
const favorites = await query const favorites = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return await this.noteFavoriteEntityService.packMany(favorites, me); return await this.noteFavoriteEntityService.packMany(favorites, me);

View file

@ -60,7 +60,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.leftJoinAndSelect('like.post', 'post'); .leftJoinAndSelect('like.post', 'post');
const likes = await query const likes = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return await this.galleryLikeEntityService.packMany(likes, me); return await this.galleryLikeEntityService.packMany(likes, me);

View file

@ -48,7 +48,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.andWhere('post.userId = :meId', { meId: me.id }); .andWhere('post.userId = :meId', { meId: me.id });
const posts = await query const posts = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return await this.galleryPostEntityService.packMany(posts, me); return await this.galleryPostEntityService.packMany(posts, me);

View file

@ -59,7 +59,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.leftJoinAndSelect('like.page', 'page'); .leftJoinAndSelect('like.page', 'page');
const likes = await query const likes = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return this.pageLikeEntityService.packMany(likes, me); return this.pageLikeEntityService.packMany(likes, me);

View file

@ -48,7 +48,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.andWhere('page.userId = :meId', { meId: me.id }); .andWhere('page.userId = :meId', { meId: me.id });
const pages = await query const pages = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return await this.pageEntityService.packMany(pages); return await this.pageEntityService.packMany(pages);

View file

@ -35,7 +35,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
const query = this.queryService.makePaginationQuery(this.signinsRepository.createQueryBuilder('signin'), ps.sinceId, ps.untilId) const query = this.queryService.makePaginationQuery(this.signinsRepository.createQueryBuilder('signin'), ps.sinceId, ps.untilId)
.andWhere('signin.userId = :meId', { meId: me.id }); .andWhere('signin.userId = :meId', { meId: me.id });
const history = await query.take(ps.limit).getMany(); const history = await query.limit(ps.limit).getMany();
return await Promise.all(history.map(record => this.signinEntityService.pack(record))); return await Promise.all(history.map(record => this.signinEntityService.pack(record)));
}); });

View file

@ -48,7 +48,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.andWhere('muting.muterId = :meId', { meId: me.id }); .andWhere('muting.muterId = :meId', { meId: me.id });
const mutings = await query const mutings = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return await this.mutingEntityService.packMany(mutings, me); return await this.mutingEntityService.packMany(mutings, me);

View file

@ -79,7 +79,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
// query.isBot = bot; // query.isBot = bot;
//} //}
const notes = await query.take(ps.limit).getMany(); const notes = await query.limit(ps.limit).getMany();
return await this.noteEntityService.packMany(notes); return await this.noteEntityService.packMany(notes);
}); });

View file

@ -68,7 +68,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
this.queryService.generateBlockedUserQuery(query, me); this.queryService.generateBlockedUserQuery(query, me);
} }
const notes = await query.take(ps.limit).getMany(); const notes = await query.limit(ps.limit).getMany();
return await this.noteEntityService.packMany(notes, me); return await this.noteEntityService.packMany(notes, me);
}); });

View file

@ -65,7 +65,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
let notes = await query let notes = await query
.orderBy('note.score', 'DESC') .orderBy('note.score', 'DESC')
.take(100) .limit(100)
.getMany(); .getMany();
notes.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()); notes.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());

View file

@ -88,7 +88,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
} }
//#endregion //#endregion
const timeline = await query.take(ps.limit).getMany(); const timeline = await query.limit(ps.limit).getMany();
process.nextTick(() => { process.nextTick(() => {
if (me) { if (me) {

View file

@ -137,7 +137,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
} }
//#endregion //#endregion
const timeline = await query.take(ps.limit).getMany(); const timeline = await query.limit(ps.limit).getMany();
process.nextTick(() => { process.nextTick(() => {
this.activeUsersChart.read(me); this.activeUsersChart.read(me);

View file

@ -110,7 +110,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
} }
//#endregion //#endregion
const timeline = await query.take(ps.limit).getMany(); const timeline = await query.limit(ps.limit).getMany();
process.nextTick(() => { process.nextTick(() => {
if (me) { if (me) {

View file

@ -79,7 +79,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
query.setParameters(followingQuery.getParameters()); query.setParameters(followingQuery.getParameters());
} }
const mentions = await query.take(ps.limit).getMany(); const mentions = await query.limit(ps.limit).getMany();
this.noteReadService.read(me.id, mentions); this.noteReadService.read(me.id, mentions);

View file

@ -82,7 +82,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
const polls = await query const polls = await query
.orderBy('poll.noteId', 'DESC') .orderBy('poll.noteId', 'DESC')
.take(ps.limit) .limit(ps.limit)
.skip(ps.offset) .skip(ps.offset)
.getMany(); .getMany();

View file

@ -71,7 +71,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
if (me) this.queryService.generateMutedUserQuery(query, me); if (me) this.queryService.generateMutedUserQuery(query, me);
if (me) this.queryService.generateBlockedUserQuery(query, me); if (me) this.queryService.generateBlockedUserQuery(query, me);
const renotes = await query.take(ps.limit).getMany(); const renotes = await query.limit(ps.limit).getMany();
return await this.noteEntityService.packMany(renotes, me); return await this.noteEntityService.packMany(renotes, me);
}); });

View file

@ -55,7 +55,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
if (me) this.queryService.generateMutedUserQuery(query, me); if (me) this.queryService.generateMutedUserQuery(query, me);
if (me) this.queryService.generateBlockedUserQuery(query, me); if (me) this.queryService.generateBlockedUserQuery(query, me);
const timeline = await query.take(ps.limit).getMany(); const timeline = await query.limit(ps.limit).getMany();
return await this.noteEntityService.packMany(timeline, me); return await this.noteEntityService.packMany(timeline, me);
}); });

View file

@ -130,7 +130,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
} }
// Search notes // Search notes
const notes = await query.take(ps.limit).getMany(); const notes = await query.limit(ps.limit).getMany();
return await this.noteEntityService.packMany(notes, me); return await this.noteEntityService.packMany(notes, me);
}); });

View file

@ -123,7 +123,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
} }
//#endregion //#endregion
const timeline = await query.take(ps.limit).getMany(); const timeline = await query.limit(ps.limit).getMany();
process.nextTick(() => { process.nextTick(() => {
this.activeUsersChart.read(me); this.activeUsersChart.read(me);

View file

@ -127,7 +127,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
} }
//#endregion //#endregion
const timeline = await query.take(ps.limit).getMany(); const timeline = await query.limit(ps.limit).getMany();
this.activeUsersChart.read(me); this.activeUsersChart.read(me);

View file

@ -41,7 +41,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.andWhere('page.likedCount > 0') .andWhere('page.likedCount > 0')
.orderBy('page.likedCount', 'DESC'); .orderBy('page.likedCount', 'DESC');
const pages = await query.take(10).getMany(); const pages = await query.limit(10).getMany();
return await this.pageEntityService.packMany(pages, me); return await this.pageEntityService.packMany(pages, me);
}); });

View file

@ -48,7 +48,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.andWhere('muting.muterId = :meId', { meId: me.id }); .andWhere('muting.muterId = :meId', { meId: me.id });
const mutings = await query const mutings = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return await this.renoteMutingEntityService.packMany(mutings, me); return await this.renoteMutingEntityService.packMany(mutings, me);

View file

@ -65,7 +65,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.innerJoinAndSelect('assign.user', 'user'); .innerJoinAndSelect('assign.user', 'user');
const assigns = await query const assigns = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return await Promise.all(assigns.map(async assign => ({ return await Promise.all(assigns.map(async assign => ({

View file

@ -80,7 +80,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
if (me) this.queryService.generateMutedUserQueryForUsers(query, me); if (me) this.queryService.generateMutedUserQueryForUsers(query, me);
if (me) this.queryService.generateBlockQueryForUsers(query, me); if (me) this.queryService.generateBlockQueryForUsers(query, me);
query.take(ps.limit); query.limit(ps.limit);
query.skip(ps.offset); query.skip(ps.offset);
const users = await query.getMany(); const users = await query.getMany();

View file

@ -48,7 +48,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.andWhere('clip.isPublic = true'); .andWhere('clip.isPublic = true');
const clips = await query const clips = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return await this.clipEntityService.packMany(clips, me); return await this.clipEntityService.packMany(clips, me);

View file

@ -112,7 +112,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.innerJoinAndSelect('following.follower', 'follower'); .innerJoinAndSelect('following.follower', 'follower');
const followings = await query const followings = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return await this.followingEntityService.packMany(followings, me, { populateFollower: true }); return await this.followingEntityService.packMany(followings, me, { populateFollower: true });

View file

@ -112,7 +112,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.innerJoinAndSelect('following.followee', 'followee'); .innerJoinAndSelect('following.followee', 'followee');
const followings = await query const followings = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return await this.followingEntityService.packMany(followings, me, { populateFollowee: true }); return await this.followingEntityService.packMany(followings, me, { populateFollowee: true });

View file

@ -47,7 +47,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.andWhere('post.userId = :userId', { userId: ps.userId }); .andWhere('post.userId = :userId', { userId: ps.userId });
const posts = await query const posts = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return await this.galleryPostEntityService.packMany(posts, me); return await this.galleryPostEntityService.packMany(posts, me);

View file

@ -120,7 +120,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
//#endregion //#endregion
const timeline = await query.take(ps.limit).getMany(); const timeline = await query.limit(ps.limit).getMany();
return await this.noteEntityService.packMany(timeline, me); return await this.noteEntityService.packMany(timeline, me);
}); });

View file

@ -48,7 +48,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.andWhere('page.visibility = \'public\''); .andWhere('page.visibility = \'public\'');
const pages = await query const pages = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return await this.pageEntityService.packMany(pages); return await this.pageEntityService.packMany(pages);

View file

@ -73,7 +73,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
this.queryService.generateVisibilityQuery(query, me); this.queryService.generateVisibilityQuery(query, me);
const reactions = await query const reactions = await query
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
return await Promise.all(reactions.map(reaction => this.noteReactionEntityService.pack(reaction, me, { withNote: true }))); return await Promise.all(reactions.map(reaction => this.noteReactionEntityService.pack(reaction, me, { withNote: true })));

View file

@ -70,7 +70,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
query.setParameters(followingQuery.getParameters()); 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 }); return await this.userEntityService.packMany(users, me, { detail: true });
}); });

View file

@ -97,7 +97,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
users = await query users = await query
.orderBy('user.usernameLower', 'ASC') .orderBy('user.usernameLower', 'ASC')
.take(ps.limit) .limit(ps.limit)
.getMany(); .getMany();
if (users.length < ps.limit) { if (users.length < ps.limit) {
@ -110,7 +110,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
const otherUsers = await otherQuery const otherUsers = await otherQuery
.orderBy('user.updatedAt', 'DESC') .orderBy('user.updatedAt', 'DESC')
.take(ps.limit - users.length) .limit(ps.limit - users.length)
.getMany(); .getMany();
users = users.concat(otherUsers); users = users.concat(otherUsers);
@ -122,7 +122,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
users = await query users = await query
.orderBy('user.updatedAt', 'DESC') .orderBy('user.updatedAt', 'DESC')
.take(ps.limit - users.length) .limit(ps.limit - users.length)
.getMany(); .getMany();
} }

View file

@ -73,7 +73,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
users = await usernameQuery users = await usernameQuery
.orderBy('user.updatedAt', 'DESC', 'NULLS LAST') .orderBy('user.updatedAt', 'DESC', 'NULLS LAST')
.take(ps.limit) .limit(ps.limit)
.skip(ps.offset) .skip(ps.offset)
.getMany(); .getMany();
} else { } else {
@ -100,7 +100,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
users = await nameQuery users = await nameQuery
.orderBy('user.updatedAt', 'DESC', 'NULLS LAST') .orderBy('user.updatedAt', 'DESC', 'NULLS LAST')
.take(ps.limit) .limit(ps.limit)
.skip(ps.offset) .skip(ps.offset)
.getMany(); .getMany();
@ -126,7 +126,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
users = users.concat(await query users = users.concat(await query
.orderBy('user.updatedAt', 'DESC', 'NULLS LAST') .orderBy('user.updatedAt', 'DESC', 'NULLS LAST')
.take(ps.limit) .limit(ps.limit)
.skip(ps.offset) .skip(ps.offset)
.getMany(), .getMany(),
); );