From 53b36b1957c155dd1e3467c7d15aae7194edcbea Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Sun, 21 Jan 2024 20:15:43 -0600 Subject: [PATCH] Fixed --- main.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/main.ts b/main.ts index 11ebba6..bf7b415 100644 --- a/main.ts +++ b/main.ts @@ -10,5 +10,18 @@ import '$std/dotenv/load.ts' import { start } from '$fresh/server.ts' import manifest from './fresh.gen.ts' import config from './fresh.config.ts' +import { kv } from '@homeman/db.ts' +import { Task } from '@homeman/models.ts' + +Deno.cron('Reset daily tasks', '0 4 * * *', async () => { + console.log('4am daily tasks reset') + const tasks = await Array.fromAsync(kv.list({ prefix: ['task'] })) + tasks.forEach( + async (t) => { + const nv = { ...t.value, doneAt: null } + await kv.set(t.key, nv) + }, + ) +}) await start(manifest, config)