mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-25 03:17:38 -07:00
perf(server): Reduce database query
This commit is contained in:
parent
5da2fc3293
commit
b54be21be8
1 changed files with 13 additions and 13 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue