summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/endpoints/roles
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-10-09 20:31:39 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2023-10-09 20:31:39 +0900
commit0bb0c329087149355a9968e7c142b9ecdf1023ec (patch)
treefbbd787c1242c7c8e598b8fc77f81398c4c32f1c /packages/backend/src/server/api/endpoints/roles
parent2023.10.0-beta.12 (diff)
downloadsharkey-0bb0c329087149355a9968e7c142b9ecdf1023ec.tar.gz
sharkey-0bb0c329087149355a9968e7c142b9ecdf1023ec.tar.bz2
sharkey-0bb0c329087149355a9968e7c142b9ecdf1023ec.zip
enhance(backend): RedisへのTLの構築をListで行うように
#11404
Diffstat (limited to 'packages/backend/src/server/api/endpoints/roles')
-rw-r--r--packages/backend/src/server/api/endpoints/roles/notes.ts14
1 files changed, 7 insertions, 7 deletions
diff --git a/packages/backend/src/server/api/endpoints/roles/notes.ts b/packages/backend/src/server/api/endpoints/roles/notes.ts
index 3f2b31c02f..366c3a7cc1 100644
--- a/packages/backend/src/server/api/endpoints/roles/notes.ts
+++ b/packages/backend/src/server/api/endpoints/roles/notes.ts
@@ -11,6 +11,7 @@ import { QueryService } from '@/core/QueryService.js';
import { DI } from '@/di-symbols.js';
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import { IdService } from '@/core/IdService.js';
+import { RedisTimelineService } from '@/core/RedisTimelineService.js';
import { ApiError } from '../../error.js';
export const meta = {
@@ -65,8 +66,12 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
private idService: IdService,
private noteEntityService: NoteEntityService,
private queryService: QueryService,
+ private redisTimelineService: RedisTimelineService,
) {
super(meta, paramDef, async (ps, me) => {
+ const untilId = ps.untilId ?? ps.untilDate ? this.idService.genId(new Date(ps.untilDate!)) : null;
+ const sinceId = ps.sinceId ?? ps.sinceDate ? this.idService.genId(new Date(ps.sinceDate!)) : null;
+
const role = await this.rolesRepository.findOneBy({
id: ps.roleId,
isPublic: true,
@@ -78,14 +83,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
if (!role.isExplorable) {
return [];
}
- const limit = ps.limit + (ps.untilId ? 1 : 0) + (ps.sinceId ? 1 : 0); // untilIdに指定したものも含まれるため+1
- const noteIds = await this.redisForTimelines.xrevrange(
- `roleTimeline:${role.id}`,
- ps.untilId ? this.idService.parse(ps.untilId).date.getTime() : ps.untilDate ?? '+',
- ps.sinceId ? this.idService.parse(ps.sinceId).date.getTime() : ps.sinceDate ?? '-',
- 'COUNT', limit,
- ).then(res => res.map(x => x[1][1]).filter(x => x !== ps.untilId && x !== ps.sinceId));
+ let noteIds = await this.redisTimelineService.get(`roleTimeline:${role.id}`, untilId, sinceId);
+ noteIds = noteIds.slice(0, ps.limit);
if (noteIds.length === 0) {
return [];