summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api
diff options
context:
space:
mode:
authorfutchitwo <74236683+futchitwo@users.noreply.github.com>2023-04-09 07:56:27 +0900
committerGitHub <noreply@github.com>2023-04-09 07:56:27 +0900
commit038365bf2d1f497385eb84ab74dba42be9c425ae (patch)
treeeedfaf47f54b2a55fee7ec9de2ea11dc9e6f0fb9 /packages/backend/src/server/api
parentUpdate CHANGELOG.md (diff)
downloadsharkey-038365bf2d1f497385eb84ab74dba42be9c425ae.tar.gz
sharkey-038365bf2d1f497385eb84ab74dba42be9c425ae.tar.bz2
sharkey-038365bf2d1f497385eb84ab74dba42be9c425ae.zip
fix: redis から取得できないチャンネル投稿はDBから取得 (#10539)
Diffstat (limited to 'packages/backend/src/server/api')
-rw-r--r--packages/backend/src/server/api/endpoints/channels/timeline.ts18
1 files changed, 12 insertions, 6 deletions
diff --git a/packages/backend/src/server/api/endpoints/channels/timeline.ts b/packages/backend/src/server/api/endpoints/channels/timeline.ts
index 2556557b24..2491d14235 100644
--- a/packages/backend/src/server/api/endpoints/channels/timeline.ts
+++ b/packages/backend/src/server/api/endpoints/channels/timeline.ts
@@ -75,13 +75,19 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
let timeline: Note[] = [];
- const noteIdsRes = await this.redisClient.xrevrange(
- `channelTimeline:${channel.id}`,
- ps.untilId ? this.idService.parse(ps.untilId).date.getTime() : '+',
- '-',
- 'COUNT', ps.limit + 1); // untilIdに指定したものも含まれるため+1
+ const limit = ps.limit + (ps.untilId ? 1 : 0); // untilIdに指定したものも含まれるため+1
+ let noteIdsRes: [string, string[]][] = [];
+
+ 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);
+ }
- if (noteIdsRes.length === 0) {
+ // redis から取得していないとき・取得数が足りないとき
+ if (noteIdsRes.length < limit) {
//#region Construct query
const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
.andWhere('note.channelId = :channelId', { channelId: channel.id })