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

@@ -21,14 +21,17 @@ import {
export function parseNote(dbNote) {
return {
...dbNote,
checkItems: dbNote.checkItems ? JSON.parse(dbNote.checkItems) : null,
labels: dbNote.labels ? JSON.parse(dbNote.labels) : null,
images: dbNote.images ? JSON.parse(dbNote.images) : null,
links: dbNote.links ? JSON.parse(dbNote.links) : null,
checkItems: dbNote.checkItems ?? null,
labels: dbNote.labels ?? null,
images: dbNote.images ?? null,
links: dbNote.links ?? null,
};
}
export function parseNoteLightweight(dbNote) {
const images = Array.isArray(dbNote.images) ? dbNote.images : [];
const labels = Array.isArray(dbNote.labels) ? dbNote.labels : null;
const checkItems = Array.isArray(dbNote.checkItems) ? dbNote.checkItems : [];
return {
id: dbNote.id,
title: dbNote.title,
@@ -37,11 +40,11 @@ export function parseNoteLightweight(dbNote) {
type: dbNote.type,
isPinned: dbNote.isPinned,
isArchived: dbNote.isArchived,
hasImages: !!dbNote.images,
imageCount: dbNote.images ? JSON.parse(dbNote.images).length : 0,
labels: dbNote.labels ? JSON.parse(dbNote.labels) : null,
hasCheckItems: !!dbNote.checkItems,
checkItemsCount: dbNote.checkItems ? JSON.parse(dbNote.checkItems).length : 0,
hasImages: images.length > 0,
imageCount: images.length,
labels,
hasCheckItems: checkItems.length > 0,
checkItemsCount: checkItems.length,
reminder: dbNote.reminder,
isReminderDone: dbNote.isReminderDone,
isMarkdown: dbNote.isMarkdown,
@@ -598,12 +601,12 @@ export function registerTools(server, prisma, options = {}) {
content: args.content,
color: args.color || 'default',
type: args.type || 'text',
checkItems: args.checkItems ? JSON.stringify(args.checkItems) : null,
labels: args.labels ? JSON.stringify(args.labels) : null,
checkItems: args.checkItems ?? null,
labels: args.labels ?? null,
isPinned: args.isPinned || false,
isArchived: args.isArchived || false,
images: args.images ? JSON.stringify(args.images) : null,
links: args.links ? JSON.stringify(args.links) : null,
images: args.images ?? null,
links: args.links ?? null,
reminder: args.reminder ? new Date(args.reminder) : null,
isReminderDone: args.isReminderDone || false,
reminderRecurrence: args.reminderRecurrence || null,
@@ -659,10 +662,10 @@ export function registerTools(server, prisma, options = {}) {
if (f in args) updateData[f] = args[f];
}
if ('content' in args) updateData.content = args.content;
if ('checkItems' in args) updateData.checkItems = args.checkItems ? JSON.stringify(args.checkItems) : null;
if ('labels' in args) updateData.labels = args.labels ? JSON.stringify(args.labels) : null;
if ('images' in args) updateData.images = args.images ? JSON.stringify(args.images) : null;
if ('links' in args) updateData.links = args.links ? JSON.stringify(args.links) : null;
if ('checkItems' in args) updateData.checkItems = args.checkItems ?? null;
if ('labels' in args) updateData.labels = args.labels ?? null;
if ('images' in args) updateData.images = args.images ?? null;
if ('links' in args) updateData.links = args.links ?? null;
if ('reminder' in args) updateData.reminder = args.reminder ? new Date(args.reminder) : null;
updateData.updatedAt = new Date();
@@ -795,7 +798,7 @@ export function registerTools(server, prisma, options = {}) {
isArchived: n.isArchived,
isMarkdown: n.isMarkdown,
size: n.size,
labels: n.labels ? JSON.parse(n.labels) : [],
labels: Array.isArray(n.labels) ? n.labels : [],
notebookId: n.notebookId,
createdAt: n.createdAt,
updatedAt: n.updatedAt,
@@ -875,7 +878,7 @@ export function registerTools(server, prisma, options = {}) {
isArchived: note.isArchived || false,
isMarkdown: note.isMarkdown || false,
size: note.size || 'small',
labels: note.labels ? JSON.stringify(note.labels) : null,
labels: note.labels ?? null,
notebookId: note.notebookId || null,
...(resolvedUserId ? { userId: resolvedUserId } : {}),
},