fix: RedisへのTLキャッシュが有効の場合にHTL/LTL/STL/リストが空になることがある問題を修正 (#12088) (#12124)

* fix: RedisTimelineが有効の場合にHTLがリセットされた状態になる問題を修正

* add: CHANGELOG.md

* fix: LTL, STLでもTLが空になることがある問題を修正

* update: CHANGELOG.md

* fix: DBへのフォールバック時にwithRenotesが考慮されていないのを修正

* feat: リストにもDBフォールバックを実装

* fix: リストのDBフォールバック時の挙動を修正

---------

Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
This commit is contained in:
yukineko 2023-10-24 14:34:32 +09:00 committed by GitHub
parent 7e15f71916
commit 0c730968a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 154 additions and 49 deletions

View file

@ -110,6 +110,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
noteIds = noteIds.slice(0, ps.limit);
let redisTimeline: MiNote[] = [];
if (noteIds.length > 0) {
const query = this.notesRepository.createQueryBuilder('note')
.where('note.id IN (:...noteIds)', { noteIds: noteIds })
@ -120,9 +122,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
.leftJoinAndSelect('renote.user', 'renoteUser')
.leftJoinAndSelect('note.channel', 'channel');
let timeline = await query.getMany();
redisTimeline = await query.getMany();
timeline = timeline.filter(note => {
redisTimeline = redisTimeline.filter(note => {
if (me && (note.userId === me.id)) {
return true;
}
@ -139,17 +141,17 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
return true;
});
// TODO: フィルタした結果件数が足りなかった場合の対応
timeline.sort((a, b) => a.id > b.id ? -1 : 1);
redisTimeline.sort((a, b) => a.id > b.id ? -1 : 1);
}
if (redisTimeline.length > 0) {
process.nextTick(() => {
if (me) {
this.activeUsersChart.read(me);
}
});
return await this.noteEntityService.packMany(timeline, me);
return await this.noteEntityService.packMany(redisTimeline, me);
} else { // fallback to db
return await this.getFromDb({
untilId,