diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2021-03-22 10:45:07 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2021-03-22 10:45:07 +0900 |
| commit | e881e1bfb3d1bf0e1a453235b5fe104f276c1392 (patch) | |
| tree | 28dc3a118cbe7a9405724c6f64ee41cfb0fd18ba /src | |
| parent | のホスト (diff) | |
| download | sharkey-e881e1bfb3d1bf0e1a453235b5fe104f276c1392.tar.gz sharkey-e881e1bfb3d1bf0e1a453235b5fe104f276c1392.tar.bz2 sharkey-e881e1bfb3d1bf0e1a453235b5fe104f276c1392.zip | |
perf(server): Reduce database query
Diffstat (limited to 'src')
| -rw-r--r-- | src/services/note/create.ts | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/services/note/create.ts b/src/services/note/create.ts index 96177e9758..4a737e8516 100644 --- a/src/services/note/create.ts +++ b/src/services/note/create.ts @@ -259,21 +259,21 @@ export default async (user: User, data: Option, silent = false) => new Promise<N }); // Antenna - Antennas.find().then(async antennas => { - const followings = await Followings.createQueryBuilder('following') - .andWhere(`following.followeeId = :userId`, { userId: note.userId }) - .getMany(); - - const followers = followings.map(f => f.followerId); - - for (const antenna of antennas) { - checkHitAntenna(antenna, note, user, followers).then(hit => { - if (hit) { - addNoteToAntenna(antenna, note, user); + Followings.createQueryBuilder('following') + .andWhere(`following.followeeId = :userId`, { userId: note.userId }) + .getMany() + .then(followings => { + const followers = followings.map(f => f.followerId); + Antennas.find().then(async antennas => { + for (const antenna of antennas) { + checkHitAntenna(antenna, note, user, followers).then(hit => { + if (hit) { + addNoteToAntenna(antenna, note, user); + } + }); } }); - } - }); + }); // Channel if (note.channelId) { |