From cd0ff94c0cc2f7981f6afbbdf72bb94541476b60 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Mon, 13 May 2024 14:51:19 +0100 Subject: [PATCH] Server: Use slave database for reports --- packages/server/src/routes/admin/reports.ts | 2 +- packages/server/src/utils/types.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/server/src/routes/admin/reports.ts b/packages/server/src/routes/admin/reports.ts index 18096f63d..6e36e2c77 100644 --- a/packages/server/src/routes/admin/reports.ts +++ b/packages/server/src/routes/admin/reports.ts @@ -33,7 +33,7 @@ router.get('admin/reports/:id', async (path: SubPath, ctx: AppContext) => { if (reportType === ReportType.UserActivity) { const query = parseQuery(ctx.query as Record); - const changes = await userActivity(ctx.joplin.db, { interval: query.intervalHours * Hour }); + const changes = await userActivity(ctx.joplin.dbSlave, { interval: query.intervalHours * Hour }); const models = ctx.joplin.models; const users = await models.user().loadByIds(changes.map(c => c.user_id), { fields: ['id', 'email'] }); diff --git a/packages/server/src/utils/types.ts b/packages/server/src/utils/types.ts index 04550182e..bd75ec13d 100644 --- a/packages/server/src/utils/types.ts +++ b/packages/server/src/utils/types.ts @@ -25,6 +25,7 @@ export interface NotificationView { interface AppContextJoplin { env: Env; db: DbConnection; + dbSlave: DbConnection; models: Models; appLogger(): LoggerWrapper; notifications: NotificationView[];