From 198be6c2af5642ce652bbe0ed187d01e14dead87 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sat, 2 Dec 2023 17:21:25 +0900 Subject: [PATCH] chore(backend): remove fallbackIfEmpty HTL will never be purged so it's no longer required --- .../src/core/FanoutTimelineEndpointService.ts | 17 +++-------------- .../api/endpoints/notes/hybrid-timeline.ts | 6 +++--- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/packages/backend/src/core/FanoutTimelineEndpointService.ts b/packages/backend/src/core/FanoutTimelineEndpointService.ts index a15ee809bc..157fcbe877 100644 --- a/packages/backend/src/core/FanoutTimelineEndpointService.ts +++ b/packages/backend/src/core/FanoutTimelineEndpointService.ts @@ -32,7 +32,7 @@ export class FanoutTimelineEndpointService { allowPartial: boolean, me?: { id: MiUser['id'] } | undefined | null, useDbFallback: boolean, - redisTimelines: (string | { name: string, fallbackIfEmpty: boolean })[], + redisTimelines: string[], noteFilter: (note: MiNote) => boolean, dbFallback: (untilId: string | null, sinceId: string | null, limit: number) => Promise, }): Promise[]> { @@ -47,7 +47,7 @@ export class FanoutTimelineEndpointService { allowPartial: boolean, me?: { id: MiUser['id'] } | undefined | null, useDbFallback: boolean, - redisTimelines: (string | { name: string, fallbackIfEmpty: boolean })[], + redisTimelines: string[], noteFilter: (note: MiNote) => boolean, dbFallback: (untilId: string | null, sinceId: string | null, limit: number) => Promise, }): Promise { @@ -57,18 +57,7 @@ export class FanoutTimelineEndpointService { // 呼び出し元と以下の処理をシンプルにするためにdbFallbackを置き換える if (!ps.useDbFallback) ps.dbFallback = () => Promise.resolve([]); - const timelines = ps.redisTimelines.map(x => typeof x === 'string' ? x : x.name); - - const redisResult = await this.fanoutTimelineService.getMulti(timelines, ps.untilId, ps.sinceId); - - for (let i = 0; i < ps.redisTimelines.length; i++) { - const sourceRedisConfig = ps.redisTimelines[i]; - if (typeof sourceRedisConfig === 'object' && sourceRedisConfig.fallbackIfEmpty) { - if (redisResult[i].length === 0) { - shouldFallbackToDb = true; - } - } - } + const redisResult = await this.fanoutTimelineService.getMulti(ps.redisTimelines, ps.untilId, ps.sinceId); const redisResultIds = Array.from(new Set(redisResult.flat(1))); diff --git a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts index b5674be838..3aefdcba10 100644 --- a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts @@ -128,18 +128,18 @@ export default class extends Endpoint { // eslint- if (ps.withFiles) { timelineConfig = [ - { name: `homeTimelineWithFiles:${me.id}`, fallbackIfEmpty: true }, + `homeTimelineWithFiles:${me.id}`, 'localTimelineWithFiles', ]; } else if (ps.withReplies) { timelineConfig = [ - { name: `homeTimeline:${me.id}`, fallbackIfEmpty: true }, + `homeTimeline:${me.id}`, 'localTimeline', 'localTimelineWithReplies', ]; } else { timelineConfig = [ - { name: `homeTimeline:${me.id}`, fallbackIfEmpty: true }, + `homeTimeline:${me.id}`, 'localTimeline', ]; }