diff options
| author | zyoshoka <107108195+zyoshoka@users.noreply.github.com> | 2024-06-22 12:43:03 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-22 12:43:03 +0900 |
| commit | 8a9de081f1efd78117c30bdc721785ca323b202c (patch) | |
| tree | 2cc7aeafff6dea52c3314453ecf9e238ade5a84a /packages/backend/src/core | |
| parent | Replace with `vue/no-setup-props-reactivity-loss` rule (#14062) (diff) | |
| download | sharkey-8a9de081f1efd78117c30bdc721785ca323b202c.tar.gz sharkey-8a9de081f1efd78117c30bdc721785ca323b202c.tar.bz2 sharkey-8a9de081f1efd78117c30bdc721785ca323b202c.zip | |
fix(backend): fallback if `sinceId` is older than the oldest in cache when using FTT (#14061)
* fix(backend): fallback if `sinceId` is older than the oldest in cache when using FTT
* Update CHANGELOG.md
* chore: fix description of test
Diffstat (limited to 'packages/backend/src/core')
| -rw-r--r-- | packages/backend/src/core/FanoutTimelineEndpointService.ts | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/packages/backend/src/core/FanoutTimelineEndpointService.ts b/packages/backend/src/core/FanoutTimelineEndpointService.ts index d5058f37c2..b05af99c5e 100644 --- a/packages/backend/src/core/FanoutTimelineEndpointService.ts +++ b/packages/backend/src/core/FanoutTimelineEndpointService.ts @@ -55,9 +55,6 @@ export class FanoutTimelineEndpointService { @bindThis private async getMiNotes(ps: TimelineOptions): Promise<MiNote[]> { - let noteIds: string[]; - let shouldFallbackToDb = false; - // 呼び出し元と以下の処理をシンプルにするためにdbFallbackを置き換える if (!ps.useDbFallback) ps.dbFallback = () => Promise.resolve([]); @@ -67,12 +64,11 @@ export class FanoutTimelineEndpointService { const redisResult = await this.fanoutTimelineService.getMulti(ps.redisTimelines, ps.untilId, ps.sinceId); // TODO: いい感じにgetMulti内でソート済だからuniqするときにredisResultが全てソート済なのを利用して再ソートを避けたい - const redisResultIds = Array.from(new Set(redisResult.flat(1))); - - redisResultIds.sort(idCompare); - noteIds = redisResultIds.slice(0, ps.limit); + const redisResultIds = Array.from(new Set(redisResult.flat(1))).sort(idCompare); - shouldFallbackToDb = shouldFallbackToDb || (noteIds.length === 0); + let noteIds = redisResultIds.slice(0, ps.limit); + const oldestNoteId = ascending ? redisResultIds[0] : redisResultIds[redisResultIds.length - 1]; + const shouldFallbackToDb = noteIds.length === 0 || ps.sinceId != null && ps.sinceId < oldestNoteId; if (!shouldFallbackToDb) { let filter = ps.noteFilter ?? (_note => true); |