Skip to content

Commit

Permalink
fixed hasActivity auto triggering
Browse files Browse the repository at this point in the history
  • Loading branch information
GhomKrosmonaute committed Oct 27, 2023
1 parent 5e82985 commit 7167d6a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/commands/active.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default new app.Command({

intervals[message.guild.id] = setInterval(
async () => {
if (await app.hasActivity(config._id, message.args.interval))
if (!(await app.hasActivity(config._id, message.args.interval)))
return await app.sendLog(
message.guild,
`Ignored automated active list update, no activity detected in the last period.`,
Expand Down
25 changes: 12 additions & 13 deletions src/namespaces/active.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,19 +190,18 @@ export async function hasActivity(
guild_id: number,
period: number,
): Promise<boolean> {
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)
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 {
Expand Down

0 comments on commit 7167d6a

Please sign in to comment.