chore: snapshot before performance optimization

This commit is contained in:
Sepehr Ramezani
2026-04-17 21:14:43 +02:00
parent b6a548acd8
commit 2eceb32fd4
95 changed files with 4357 additions and 1942 deletions

View File

@@ -3,6 +3,7 @@
import prisma from '@/lib/prisma'
import { auth } from '@/auth'
import { sendEmail } from '@/lib/mail'
import { revalidateTag } from 'next/cache'
async function checkAdmin() {
const session = await auth()
@@ -29,11 +30,9 @@ export async function testSMTP() {
export async function getSystemConfig() {
await checkAdmin()
const configs = await prisma.systemConfig.findMany()
return configs.reduce((acc, conf) => {
acc[conf.key] = conf.value
return acc
}, {} as Record<string, string>)
// Reuse the cached version from lib/config
const { getSystemConfig: getCachedConfig } = await import('@/lib/config')
return getCachedConfig()
}
export async function updateSystemConfig(data: Record<string, string>) {
@@ -45,8 +44,6 @@ export async function updateSystemConfig(data: Record<string, string>) {
Object.entries(data).filter(([key, value]) => value !== '' && value !== null && value !== undefined)
)
const operations = Object.entries(filteredData).map(([key, value]) =>
prisma.systemConfig.upsert({
where: { key },
@@ -56,6 +53,10 @@ export async function updateSystemConfig(data: Record<string, string>) {
)
await prisma.$transaction(operations)
// Invalidate cache after update
revalidateTag('system-config', '/settings')
return { success: true }
} catch (error) {
console.error('Failed to update settings:', error)

View File

@@ -410,7 +410,6 @@ export async function createNote(data: {
isMarkdown: data.isMarkdown || false,
size: data.size || 'small',
embedding: null, // Generated in background
sharedWith: data.sharedWith && data.sharedWith.length > 0 ? JSON.stringify(data.sharedWith) : null,
autoGenerated: data.autoGenerated || null,
notebookId: data.notebookId || null,
}