Commit graph

12 commits

Author SHA1 Message Date
esdrasrenan
638faeb287 fix(convex): corrigir memory leak com .collect() sem limite e adicionar otimizacoes
Problema: Convex backend consumindo 16GB+ de RAM causando OOM kills

Correcoes aplicadas:
- Substituido todos os .collect() por .take(LIMIT) em 27+ arquivos
- Adicionado indice by_usbPolicyStatus para otimizar query de maquinas
- Corrigido N+1 problem em alerts.ts usando Map lookup
- Corrigido full table scan em usbPolicy.ts
- Corrigido subscription leaks no frontend (tickets-view, use-ticket-categories)
- Atualizado versao do Convex backend para precompiled-2025-12-04-cc6af4c

Arquivos principais modificados:
- convex/*.ts - limites em todas as queries .collect()
- convex/schema.ts - novo indice by_usbPolicyStatus
- convex/alerts.ts - N+1 fix com Map
- convex/usbPolicy.ts - uso do novo indice
- src/components/tickets/tickets-view.tsx - skip condicional
- src/hooks/use-ticket-categories.ts - skip condicional

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-09 21:41:30 -03:00
rever-tecnologia
3a37892864 refactor(convex): replace collect() with take() to prevent OOM
- liveChat.ts: limit sessions/messages queries (take 50-500)
- tickets.ts: batch delete operations, limit playNext/reassign (take 100-2000)
- reports.ts: limit ticket/user/machine queries (take 500-2000)
- machines.ts: limit machine queries for registration/listing (take 500)
- metrics.ts: limit device health summary (take 200)
- users.ts: limit user search in claimInvite (take 5000)
- alerts.ts: limit company/alert queries (take 500-1000)
- migrations.ts: limit batch operations (take 1000-2000)

These changes prevent the Convex backend from loading entire tables
into memory, which was causing OOM kills at 16GB and WebSocket
disconnections (code 1006).

Expected RAM reduction: 60-80% at peak usage.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-09 19:23:10 -03:00
Esdras Renan
714b199879 feat: export reports as xlsx and add machine inventory 2025-10-27 18:00:28 -03:00
codex-bot
4aee7d7719 Permite selecionar solicitante e empresa nos tickets 2025-10-23 17:47:23 -03:00
Esdras Renan
216feca971 feat(tickets): preserve requester/assignee/company snapshots + timeline fallbacks; chore: add requester index\n\n- Add requesterSnapshot, assigneeSnapshot, companySnapshot to tickets\n- Use snapshots as fallback in list/get/play\n- Update snapshots on assignee changes/startWork\n- Preserve snapshots before deleting users/companies\n- Add index tickets.by_tenant_requester\n- Add migrations.backfillTicketSnapshots\n\nchore(convex): upgrade to ^1.28.0 and run codegen\nchore(next): upgrade Next.js to 15.5.6 and update React/eslint-config-next\nfix: remove any and lint warnings; tighten types across API routes and components\ndocs: add docs/ticket-snapshots.md 2025-10-20 10:13:37 -03:00
Esdras Renan
63d6a65334 chore: snapshot comment authors before user deletion 2025-10-19 14:30:59 -03:00
Esdras Renan
846e575637 fix: harden machine session fallback and clean lint 2025-10-19 03:16:50 -03:00
Esdras Renan
2607ca5ce3 Assignee picker: return only ADMIN/AGENT (exclude collaborators/managers) 2025-10-19 03:03:10 -03:00
Esdras Renan
05f5af5ba6 Enable admin user removals and invitation UX polish 2025-10-13 15:08:51 -03:00
Esdras Renan
b5fd920efd docs: registrar fluxo do updater e atualizar chaves 2025-10-12 04:06:29 -03:00
Esdras Renan
3bafcc5a0a feat: CSV exports, PDF improvements, play internal/external with hour split, roles cleanup, admin companies with 'Cliente avulso', ticket list spacing/alignment fixes, status translations and mappings 2025-10-07 13:42:45 -03:00
Esdras Renan
1cccb852a5 chore: reorganize project structure and ensure default queues 2025-10-06 22:59:35 -03:00
Renamed from web/convex/users.ts (Browse further)