remove lógica de paginação duplicada no fetchChats que causa resultados vazios quando skip > 0 #1736
+0
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problema
O método
fetchChats
estava aplicando a lógica de paginação duas vezes, causando resultados vazios ao usar o parâmetroskip
com valores maiores que 0.Causa Raiz
LIMIT
eOFFSET
corretamente.slice(skip, skip + take)
nos resultados já paginadosExemplo do bug
Requisição: {"take": 10, "skip": 10}
LIMIT 10 OFFSET 10
→ retorna chats 11-20 (10 itens).slice(10, 20)
→ tenta pegar posições 10-20 de um array com apenas 10 itens[]
(array vazio)Testes
{"take": 10, "skip": 0}
- Retorna os primeiros 10 chats{"take": 10, "skip": 10}
- Retorna chats 11-20 (anteriormente retornava[]
){"take": 5, "skip": 15}
- Retorna chats 16-20 (anteriormente retornava[]
)Impacto
skip > 0
Summary by Sourcery
Remove duplicated pagination logic in fetchChats by deleting the JavaScript slice, relying solely on SQL LIMIT and OFFSET to fix empty results with skip offsets
Bug Fixes:
Enhancements:
Tests: