diff options
Diffstat (limited to 'packages/backend/src/daemons/janitor.ts')
| -rw-r--r-- | packages/backend/src/daemons/janitor.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/packages/backend/src/daemons/janitor.ts b/packages/backend/src/daemons/janitor.ts new file mode 100644 index 0000000000..72568cfe18 --- /dev/null +++ b/packages/backend/src/daemons/janitor.ts @@ -0,0 +1,20 @@ +// TODO: 消したい + +const interval = 30 * 60 * 1000; +import { AttestationChallenges } from '@/models/index'; +import { LessThan } from 'typeorm'; + +/** + * Clean up database occasionally + */ +export default function() { + async function tick() { + await AttestationChallenges.delete({ + createdAt: LessThan(new Date(new Date().getTime() - 5 * 60 * 1000)) + }); + } + + tick(); + + setInterval(tick, interval); +} |