diff options
| author | dakkar <dakkar@thenautilus.net> | 2024-05-31 12:26:07 +0100 |
|---|---|---|
| committer | dakkar <dakkar@thenautilus.net> | 2024-05-31 12:26:07 +0100 |
| commit | 3372e0ffe153d996bdf04ae3d834633d0ba18fca (patch) | |
| tree | 7a46452030b2a2ca24d1ea9158fa5f0f75000245 /packages/backend/src/core/FanoutTimelineEndpointService.ts | |
| parent | Merge branch 'develop' into future (diff) | |
| parent | Bump version to 2024.5.0-rc.9 (diff) | |
| download | sharkey-3372e0ffe153d996bdf04ae3d834633d0ba18fca.tar.gz sharkey-3372e0ffe153d996bdf04ae3d834633d0ba18fca.tar.bz2 sharkey-3372e0ffe153d996bdf04ae3d834633d0ba18fca.zip | |
Merge remote-tracking branch 'misskey/release/2024.5.0' into future
Diffstat (limited to 'packages/backend/src/core/FanoutTimelineEndpointService.ts')
| -rw-r--r-- | packages/backend/src/core/FanoutTimelineEndpointService.ts | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/packages/backend/src/core/FanoutTimelineEndpointService.ts b/packages/backend/src/core/FanoutTimelineEndpointService.ts index 2f4d98fab4..5725c795ed 100644 --- a/packages/backend/src/core/FanoutTimelineEndpointService.ts +++ b/packages/backend/src/core/FanoutTimelineEndpointService.ts @@ -62,8 +62,8 @@ export class FanoutTimelineEndpointService { // 呼び出し元と以下の処理をシンプルにするためにdbFallbackを置き換える if (!ps.useDbFallback) ps.dbFallback = () => Promise.resolve([]); - const shouldPrepend = ps.sinceId && !ps.untilId; - const idCompare: (a: string, b: string) => number = shouldPrepend ? (a, b) => a < b ? -1 : 1 : (a, b) => a > b ? -1 : 1; + const ascending = ps.sinceId && !ps.untilId; + const idCompare: (a: string, b: string) => number = ascending ? (a, b) => a < b ? -1 : 1 : (a, b) => a > b ? -1 : 1; const redisResult = await this.fanoutTimelineService.getMulti(ps.redisTimelines, ps.untilId, ps.sinceId); @@ -148,9 +148,7 @@ export class FanoutTimelineEndpointService { if (ps.allowPartial ? redisTimeline.length !== 0 : redisTimeline.length >= ps.limit) { // 十分Redisからとれた - const result = redisTimeline.slice(0, ps.limit); - if (shouldPrepend) result.reverse(); - return result; + return redisTimeline.slice(0, ps.limit); } } @@ -158,8 +156,7 @@ export class FanoutTimelineEndpointService { const remainingToRead = ps.limit - redisTimeline.length; let dbUntil: string | null; let dbSince: string | null; - if (shouldPrepend) { - redisTimeline.reverse(); + if (ascending) { dbUntil = ps.untilId; dbSince = noteIds[noteIds.length - 1]; } else { @@ -167,7 +164,7 @@ export class FanoutTimelineEndpointService { dbSince = ps.sinceId; } const gotFromDb = await ps.dbFallback(dbUntil, dbSince, remainingToRead); - return shouldPrepend ? [...gotFromDb, ...redisTimeline] : [...redisTimeline, ...gotFromDb]; + return [...redisTimeline, ...gotFromDb]; } return await ps.dbFallback(ps.untilId, ps.sinceId, ps.limit); |