feat: refactor character history schema and related logic for improved date handling and data integrity
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user