From a675d557aaa18fe046832beff63509cfbae49124 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 27 Apr 2019 11:17:03 +0900 Subject: [PATCH] Improve performance --- src/server/api/endpoints/notes/global-timeline.ts | 8 +++++--- src/server/api/endpoints/notes/hybrid-timeline.ts | 8 +++++--- src/server/api/endpoints/notes/local-timeline.ts | 8 +++++--- src/server/api/endpoints/notes/timeline.ts | 6 +++++- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/server/api/endpoints/notes/global-timeline.ts b/src/server/api/endpoints/notes/global-timeline.ts index 3631208da..f46fa208d 100644 --- a/src/server/api/endpoints/notes/global-timeline.ts +++ b/src/server/api/endpoints/notes/global-timeline.ts @@ -89,9 +89,11 @@ export default define(meta, async (ps, user) => { const timeline = await query.take(ps.limit!).getMany(); - if (user) { - activeUsersChart.update(user); - } + process.nextTick(() => { + if (user) { + activeUsersChart.update(user); + } + }); return await Notes.packMany(timeline, user); }); diff --git a/src/server/api/endpoints/notes/hybrid-timeline.ts b/src/server/api/endpoints/notes/hybrid-timeline.ts index c05c8dedd..7be13fc47 100644 --- a/src/server/api/endpoints/notes/hybrid-timeline.ts +++ b/src/server/api/endpoints/notes/hybrid-timeline.ts @@ -192,9 +192,11 @@ export default define(meta, async (ps, user) => { const timeline = await query.take(ps.limit!).getMany(); - if (user) { - activeUsersChart.update(user); - } + process.nextTick(() => { + if (user) { + activeUsersChart.update(user); + } + }); return await Notes.packMany(timeline, user); }); diff --git a/src/server/api/endpoints/notes/local-timeline.ts b/src/server/api/endpoints/notes/local-timeline.ts index ca84fc6ef..73cbebace 100644 --- a/src/server/api/endpoints/notes/local-timeline.ts +++ b/src/server/api/endpoints/notes/local-timeline.ts @@ -125,9 +125,11 @@ export default define(meta, async (ps, user) => { const timeline = await query.take(ps.limit!).getMany(); - if (user) { - activeUsersChart.update(user); - } + process.nextTick(() => { + if (user) { + activeUsersChart.update(user); + } + }); return await Notes.packMany(timeline, user); }); diff --git a/src/server/api/endpoints/notes/timeline.ts b/src/server/api/endpoints/notes/timeline.ts index 5e692db38..f9442f8b9 100644 --- a/src/server/api/endpoints/notes/timeline.ts +++ b/src/server/api/endpoints/notes/timeline.ts @@ -177,7 +177,11 @@ export default define(meta, async (ps, user) => { const timeline = await query.take(ps.limit!).getMany(); - activeUsersChart.update(user); + process.nextTick(() => { + if (user) { + activeUsersChart.update(user); + } + }); return await Notes.packMany(timeline, user); });