feat: MVP-3 Sprint 1 - Usage tracking, smart dashboard, scoring boost

## 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>
This commit is contained in:
2026-03-22 16:03:14 -03:00
parent cc4b2453b1
commit 05b8f3910d
16 changed files with 2038 additions and 73 deletions

View File

@@ -1,4 +1,5 @@
import { prisma } from '@/lib/prisma'
import { getUsageStats } from '@/lib/usage'
// Stop words to filter out from content matching (English + Spanish)
const STOP_WORDS = new Set([
@@ -141,6 +142,16 @@ export async function getRelatedNotes(noteId: string, limit = 5): Promise<Scored
reasons.push(`Content: ${sharedContentWords.slice(0, 2).join(', ')}`)
}
// Usage-based boost (small, does not eclipse content matching)
// +1 per 5 views (max +3), +2 if used recently (recency)
const usageStats = await getUsageStats(other.id, 7) // last 7 days for recency
const viewBoost = Math.min(Math.floor(usageStats.views / 5), 3)
score += viewBoost
// Recency: if used in last 7 days, add +2
if (usageStats.views >= 1 || usageStats.relatedClicks >= 1) {
score += 2
}
// Solo incluir si tiene score > 0 Y al menos una razón válida
if (score > 0 && reasons.length > 0) {
scored.push({