mirror of
https://activitypub.software/TransFem-org/Sharkey
synced 2024-11-25 07:25:12 +00:00
perf(backend): ノート作成時のアンテナ追加パフォーマンスを改善
This commit is contained in:
parent
da83322200
commit
77f91d67b4
3 changed files with 30 additions and 16 deletions
11
CHANGELOG.md
11
CHANGELOG.md
|
@ -12,6 +12,17 @@
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
## 13.x.x (unreleased)
|
||||||
|
|
||||||
|
### General
|
||||||
|
-
|
||||||
|
|
||||||
|
### Client
|
||||||
|
-
|
||||||
|
|
||||||
|
### Server
|
||||||
|
- ノート作成時のアンテナ追加パフォーマンスを改善
|
||||||
|
|
||||||
## 13.11.2
|
## 13.11.2
|
||||||
|
|
||||||
### Note
|
### Note
|
||||||
|
|
|
@ -91,8 +91,15 @@ export class AntennaService implements OnApplicationShutdown {
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async addNoteToAntenna(antenna: Antenna, note: Note, noteUser: { id: User['id']; }): Promise<void> {
|
public async addNoteToAntennas(note: Note, noteUser: { id: User['id']; username: string; host: string | null; }): Promise<void> {
|
||||||
this.redisClient.xadd(
|
const antennas = await this.getAntennas();
|
||||||
|
const antennasWithMatchResult = await Promise.all(antennas.map(antenna => this.checkHitAntenna(antenna, note, noteUser).then(hit => [antenna, hit] as const)));
|
||||||
|
const matchedAntennas = antennasWithMatchResult.filter(([, hit]) => hit).map(([antenna]) => antenna);
|
||||||
|
|
||||||
|
const redisPipeline = this.redisClient.pipeline();
|
||||||
|
|
||||||
|
for (const antenna of matchedAntennas) {
|
||||||
|
redisPipeline.xadd(
|
||||||
`antennaTimeline:${antenna.id}`,
|
`antennaTimeline:${antenna.id}`,
|
||||||
'MAXLEN', '~', '200',
|
'MAXLEN', '~', '200',
|
||||||
'*',
|
'*',
|
||||||
|
@ -101,6 +108,9 @@ export class AntennaService implements OnApplicationShutdown {
|
||||||
this.globalEventService.publishAntennaStream(antenna.id, 'note', note);
|
this.globalEventService.publishAntennaStream(antenna.id, 'note', note);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
redisPipeline.exec();
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: フォローしているユーザーのノート、リストのユーザーのノート、グループのユーザーのノート指定はパフォーマンス上の理由で無効になっている
|
// NOTE: フォローしているユーザーのノート、リストのユーザーのノート、グループのユーザーのノート指定はパフォーマンス上の理由で無効になっている
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
|
|
@ -493,14 +493,7 @@ export class NoteCreateService implements OnApplicationShutdown {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Antenna
|
this.antennaService.addNoteToAntennas(note, user);
|
||||||
for (const antenna of (await this.antennaService.getAntennas())) {
|
|
||||||
this.antennaService.checkHitAntenna(antenna, note, user).then(hit => {
|
|
||||||
if (hit) {
|
|
||||||
this.antennaService.addNoteToAntenna(antenna, note, user);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.reply) {
|
if (data.reply) {
|
||||||
this.saveReply(data.reply, note);
|
this.saveReply(data.reply, note);
|
||||||
|
|
Loading…
Reference in a new issue