Skip to content
Snippets Groups Projects
Commit e881e1bf authored by syuilo's avatar syuilo
Browse files

perf(server): Reduce database query

parent 9e6cdd61
No related branches found
No related tags found
No related merge requests found
......@@ -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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment