From f676d12d0b45f7fb3ef25b3236068016305b0dfc Mon Sep 17 00:00:00 2001 From: GhomKrosmonaute Date: Mon, 23 Oct 2023 21:46:50 +0200 Subject: [PATCH] fixed active auto update --- src/app/database.ts | 2 +- src/commands/active.ts | 2 +- src/namespaces/active.ts | 30 ++++++++++++++++++------------ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/app/database.ts b/src/app/database.ts index 0796468a..dbe8ba45 100644 --- a/src/app/database.ts +++ b/src/app/database.ts @@ -22,4 +22,4 @@ export const orm = new ORM({ logger, }) -export * from "@ghom/orm" \ No newline at end of file +export * from "@ghom/orm" diff --git a/src/commands/active.ts b/src/commands/active.ts index d0dbbd9a..aaa10374 100644 --- a/src/commands/active.ts +++ b/src/commands/active.ts @@ -79,7 +79,7 @@ export default new app.Command({ if (await app.hasActivity(config._id, message.args.interval)) return await app.sendLog( message.guild, - `Ignored automated active list hourly update, no activity in the last hour.` + `Ignored automated active list update, no activity detected in the last period.` ) const found = await app.updateActive(message.guild, { diff --git a/src/namespaces/active.ts b/src/namespaces/active.ts index 785a23c2..76d6791e 100644 --- a/src/namespaces/active.ts +++ b/src/namespaces/active.ts @@ -181,22 +181,28 @@ export async function updateActive( return activeMembers.length } +/** + * @fixme + * @param guild_id + * @param period + */ export async function hasActivity( guild_id: number, period: number ): Promise { - return app.orm - .raw( - `select - count(*) > 0 as hasActivity - from message - where - guild_id = ${guild_id} - and - unixepoch(datetime(created_at, 'localtime')) > - unixepoch(datetime('now', '-${period} hours', 'localtime'))` - ) - .then((result) => !!result[0]?.hasActivity) + return true + // return app.orm + // .raw( + // `select + // count(*) > 0 as hasActivity + // from message + // where + // guild_id = ${guild_id} + // and + // unixepoch(datetime(created_at, 'localtime')) > + // unixepoch(datetime('now', '-${period} hours', 'localtime'))` + // ) + // .then((result) => !!result[0]?.hasActivity) } export interface ActiveLadderLine {