Keep/keep-notes/scripts/check-labels.js
sepehr 640fcb26f7 fix: improve note interactions and markdown LaTeX support
## Bug Fixes

### Note Card Actions
- Fix broken size change functionality (missing state declaration)
- Implement React 19 useOptimistic for instant UI feedback
- Add startTransition for non-blocking updates
- Ensure smooth animations without page refresh
- All note actions now work: pin, archive, color, size, checklist

### Markdown LaTeX Rendering
- Add remark-math and rehype-katex plugins
- Support inline equations with dollar sign syntax
- Support block equations with double dollar sign syntax
- Import KaTeX CSS for proper styling
- Equations now render correctly instead of showing raw LaTeX

## Technical Details

- Replace undefined currentNote references with optimistic state
- Add optimistic updates before server actions for instant feedback
- Use router.refresh() in transitions for smart cache invalidation
- Install remark-math, rehype-katex, and katex packages

## Testing

- Build passes successfully with no TypeScript errors
- Dev server hot-reloads changes correctly
2026-01-09 22:13:49 +01:00

77 lines
2.2 KiB
JavaScript

// Import directly from the generated client
const { PrismaClient } = require('./node_modules/@prisma/client')
const prisma = new PrismaClient()
async function checkLabels() {
try {
console.log('\n=== TOUS LES LABELS DANS LA TABLE Label ===')
const allLabels = await prisma.label.findMany({
select: { id: true, name: true, userId: true }
})
console.log(`Total: ${allLabels.length} labels`)
allLabels.forEach(l => {
console.log(` - ${l.name} (userId: ${l.userId}, id: ${l.id})`)
})
console.log('\n=== TOUS LES LABELS DANS LES NOTES (Note.labels) ===')
const allNotes = await prisma.note.findMany({
select: { id: true, labels: true, userId: true }
})
const labelsInNotes = new Set()
allNotes.forEach(note => {
if (note.labels) {
try {
const parsed = JSON.parse(note.labels)
if (Array.isArray(parsed)) {
parsed.forEach(l => labelsInNotes.add(l))
}
} catch (e) {}
}
})
console.log(`Total unique: ${labelsInNotes.size} labels`)
labelsInNotes.forEach(l => console.log(` - ${l}`))
console.log('\n=== LABELS ORPHELINS (dans Label table MAIS PAS dans les notes) ===')
const orphanLabels = []
allLabels.forEach(label => {
let found = false
labelsInNotes.forEach(noteLabel => {
if (noteLabel.toLowerCase() === label.name.toLowerCase()) {
found = true
}
})
if (!found) {
orphanLabels.push(label)
}
})
console.log(`Total orphans: ${orphanLabels.length}`)
orphanLabels.forEach(l => {
console.log(` - ${l.name} (userId: ${l.userId})`)
})
console.log('\n=== LABELS MANQUANTS (dans notes MAIS PAS dans Label table) ===')
const missingLabels = []
const existingLabelNames = new Set()
allLabels.forEach(l => existingLabelNames.add(l.name.toLowerCase()))
labelsInNotes.forEach(noteLabel => {
if (!existingLabelNames.has(noteLabel.toLowerCase())) {
missingLabels.push(noteLabel)
}
})
console.log(`Total missing: ${missingLabels.length}`)
missingLabels.forEach(l => console.log(` - ${l}`))
} catch (error) {
console.error('Error:', error)
} finally {
await prisma.$disconnect()
}
}
checkLabels()