## Registro de Uso - Nuevo modelo NoteUsage en Prisma - Tipos de eventos: view, search_click, related_click, link_click, copy_command, copy_snippet - Funciones: trackNoteUsage, getUsageStats, getRecentlyUsedNotes - localStorage: recentlyViewed (últimas 10 notas) - Rastreo de copias en markdown-content.tsx ## Dashboard Rediseñado - 5 bloques: Recientes, Más usadas, Comandos recientes, Snippets recientes, Según actividad - Nuevo src/lib/dashboard.ts con getDashboardData() - Recomendaciones basadas en recentlyViewed ## Scoring con Uso Real - search.ts: +1 per 5 views (max +3), +2 recency boost - related.ts: mismo sistema de usage boost - No eclipsa match textual fuerte ## Tests - 110 tests pasando (usage, dashboard, related, search) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
63 lines
1.7 KiB
Plaintext
63 lines
1.7 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "sqlite"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model Note {
|
|
id String @id @default(cuid())
|
|
title String
|
|
content String
|
|
type String @default("note")
|
|
isFavorite Boolean @default(false)
|
|
isPinned Boolean @default(false)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
tags NoteTag[]
|
|
backlinks Backlink[] @relation("BacklinkTarget")
|
|
outbound Backlink[] @relation("BacklinkSource")
|
|
usageEvents NoteUsage[]
|
|
}
|
|
|
|
model Tag {
|
|
id String @id @default(cuid())
|
|
name String @unique
|
|
notes NoteTag[]
|
|
}
|
|
|
|
model NoteTag {
|
|
noteId String
|
|
tagId String
|
|
note Note @relation(fields: [noteId], references: [id], onDelete: Cascade)
|
|
tag Tag @relation(fields: [tagId], references: [id], onDelete: Cascade)
|
|
|
|
@@id([noteId, tagId])
|
|
}
|
|
|
|
model Backlink {
|
|
id String @id @default(cuid())
|
|
sourceNoteId String
|
|
targetNoteId String
|
|
sourceNote Note @relation("BacklinkSource", fields: [sourceNoteId], references: [id], onDelete: Cascade)
|
|
targetNote Note @relation("BacklinkTarget", fields: [targetNoteId], references: [id], onDelete: Cascade)
|
|
createdAt DateTime @default(now())
|
|
|
|
@@unique([sourceNoteId, targetNoteId])
|
|
}
|
|
|
|
model NoteUsage {
|
|
id String @id @default(cuid())
|
|
noteId String
|
|
note Note @relation(fields: [noteId], references: [id], onDelete: Cascade)
|
|
eventType String // 'view' | 'search_click' | 'related_click' | 'link_click'
|
|
query String?
|
|
metadata String?
|
|
createdAt DateTime @default(now())
|
|
|
|
@@index([noteId, createdAt])
|
|
@@index([eventType, createdAt])
|
|
}
|