Refactor: const naming

This commit is contained in:
taichanne30 2024-07-25 14:37:09 +09:00
parent 685fc2bd9d
commit 3564bf5c66
No known key found for this signature in database
GPG key ID: 1D5EE39F870DC283

View file

@ -67,12 +67,12 @@ export class FanoutTimelineEndpointService {
let shouldFallbackToDb = ps.useDbFallback && (redisResult.length > 1 && redisResult.some(ids => ids.length === 0)); let shouldFallbackToDb = ps.useDbFallback && (redisResult.length > 1 && redisResult.some(ids => ids.length === 0));
// 取得したresultの中で最古のIDのうち、最も新しいものを取得 // 取得したresultの中で最古のIDのうち、最も新しいものを取得
const thresholdId = redisResult.map(ids => ids[0]).sort()[0]; const fttThresholdId = redisResult.map(ids => ids[0]).sort()[0];
// TODO: いい感じにgetMulti内でソート済だからuniqするときにredisResultが全てソート済なのを利用して再ソートを避けたい // TODO: いい感じにgetMulti内でソート済だからuniqするときにredisResultが全てソート済なのを利用して再ソートを避けたい
const redisResultIds = shouldFallbackToDb ? [] : Array.from(new Set(redisResult.flat(1))).sort(idCompare); const redisResultIds = shouldFallbackToDb ? [] : Array.from(new Set(redisResult.flat(1))).sort(idCompare);
let noteIds = redisResultIds.filter(id => id >= thresholdId).slice(0, ps.limit); let noteIds = redisResultIds.filter(id => id >= fttThresholdId).slice(0, ps.limit);
const oldestNoteId = ascending ? redisResultIds[0] : redisResultIds[redisResultIds.length - 1]; const oldestNoteId = ascending ? redisResultIds[0] : redisResultIds[redisResultIds.length - 1];
shouldFallbackToDb ||= noteIds.length === 0 || ps.sinceId != null && ps.sinceId < oldestNoteId; shouldFallbackToDb ||= noteIds.length === 0 || ps.sinceId != null && ps.sinceId < oldestNoteId;