feat: update daily character management and local storage handling

This commit is contained in:
2026-03-01 16:43:54 +01:00
parent 0b81e9e350
commit 00bd718699
5 changed files with 39 additions and 42 deletions

View File

@@ -2,7 +2,7 @@ import { createClient } from '@libsql/client';
import { drizzle } from 'drizzle-orm/libsql';
import { eq } from 'drizzle-orm';
import fs from 'fs';
import { character } from '../src/lib/server/db/schema';
import { character, characterHistory } from '../src/lib/server/db/schema';
const DATABASE_URL = process.env.DATABASE_URL || 'file:local.db';
@@ -70,6 +70,16 @@ async function setDailyCharacters(): Promise<void> {
if (errorCount === 0) {
console.log(`\n✅ Successfully set ${successCount} characters as daily mode characters\n`);
}
// Step 3: Delete only today's character from characterHistory
console.log('Step 3: Cleaning up today\'s characterHistory...');
try {
const todayDate = new Date(new Date().setHours(1, 0, 0, 0)).toISOString().split('T')[0];
await db.delete(characterHistory).where(eq(characterHistory.date, todayDate));
console.log(`✓ Character history cleared for ${todayDate}\n`);
} catch (error) {
console.error('✗ Error clearing character history:', getErrorMessage(error));
}
} catch (error) {
console.error('✗ Operation failed:', getErrorMessage(error));
process.exit(1);