feat: refactor character history schema and related logic for improved date handling and data integrity

This commit is contained in:
2026-03-02 12:19:56 +01:00
parent ef7ef4dd6c
commit 60d2474f51
6 changed files with 1126 additions and 12 deletions

View File

@@ -3,6 +3,7 @@ import { db } from '$lib/server/db';
import { characterHistory } from '$lib/server/db/schema';
import { eq } from 'drizzle-orm';
import { sql } from 'drizzle-orm';
import { getDateKey } from '$lib/server/daily-character';
export async function POST({ request }) {
try {
@@ -12,9 +13,7 @@ export async function POST({ request }) {
return json({ error: 'Missing characterId' }, { status: 400 });
}
const today = new Date();
today.setHours(0, 0, 0, 0);
const todayDate = today.toISOString().split('T')[0];
const todayDate = getDateKey(new Date());
// Increment the won counter for today's entry
await db