mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-06-11 11:41:02 -05:00
* Initial * Move code * More events implemented * Auto refresh take in account recent revalidates * Add sound effects * Add creds * Settings * Add error handling * Add envs
35 lines
820 B
TypeScript
35 lines
820 B
TypeScript
import { sql } from "~/db/sql";
|
|
|
|
interface AdminService {
|
|
cleanUp: () => void;
|
|
}
|
|
|
|
const removeOldLikesStm = sql.prepare(/*sql*/ `
|
|
delete from
|
|
"GroupLike"
|
|
where
|
|
"GroupLike"."createdAt" < cast(strftime('%s', datetime('now', 'start of day', '-7 days')) as int)
|
|
`);
|
|
|
|
const removeOldGroupStm = sql.prepare(/*sql*/ `
|
|
delete from
|
|
"Group"
|
|
where "Group"."id" in (
|
|
select "Group"."id"
|
|
from "Group"
|
|
left join "GroupMatch" on "Group"."id" = "GroupMatch"."alphaGroupId" or "Group"."id" = "GroupMatch"."bravoGroupId"
|
|
where "Group"."status" = 'INACTIVE'
|
|
and "GroupMatch"."id" is null
|
|
)
|
|
`);
|
|
|
|
const cleanUpStm = sql.prepare(/*sql*/ `
|
|
vacuum
|
|
`);
|
|
|
|
export const cleanUp: AdminService["cleanUp"] = () => {
|
|
removeOldLikesStm.run();
|
|
removeOldGroupStm.run();
|
|
cleanUpStm.run();
|
|
};
|