fix: redis から取得できないチャンネル投稿はDBから取得 (#10539)
This commit is contained in:
parent
64597a2dab
commit
038365bf2d
@ -75,13 +75,19 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||||||
|
|
||||||
let timeline: Note[] = [];
|
let timeline: Note[] = [];
|
||||||
|
|
||||||
const noteIdsRes = await this.redisClient.xrevrange(
|
const limit = ps.limit + (ps.untilId ? 1 : 0); // untilIdに指定したものも含まれるため+1
|
||||||
`channelTimeline:${channel.id}`,
|
let noteIdsRes: [string, string[]][] = [];
|
||||||
ps.untilId ? this.idService.parse(ps.untilId).date.getTime() : '+',
|
|
||||||
'-',
|
|
||||||
'COUNT', ps.limit + 1); // untilIdに指定したものも含まれるため+1
|
|
||||||
|
|
||||||
if (noteIdsRes.length === 0) {
|
if (!ps.sinceId && !ps.sinceDate) {
|
||||||
|
noteIdsRes = await this.redisClient.xrevrange(
|
||||||
|
`channelTimeline:${channel.id}`,
|
||||||
|
ps.untilId ? this.idService.parse(ps.untilId).date.getTime() : ps.untilDate ?? '+',
|
||||||
|
'-',
|
||||||
|
'COUNT', limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
// redis から取得していないとき・取得数が足りないとき
|
||||||
|
if (noteIdsRes.length < limit) {
|
||||||
//#region Construct query
|
//#region Construct query
|
||||||
const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
|
const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
|
||||||
.andWhere('note.channelId = :channelId', { channelId: channel.id })
|
.andWhere('note.channelId = :channelId', { channelId: channel.id })
|
||||||
|
Loading…
Reference in New Issue
Block a user