-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Corrigindo um bug no endpoint de findChats e permitindo paginação nos endpoints de findChats e findContacts #1334
Conversation
Reviewer's Guide by SourceryThis pull request fixes a bug in the Sequence diagram for fetching chat namesequenceDiagram
participant Client
participant ChannelStartupService
participant PrismaRepository
Client->>ChannelStartupService: Calls findChats endpoint
ChannelStartupService->>PrismaRepository: Executes raw SQL query to fetch chats
PrismaRepository-->>ChannelStartupService: Returns chat data including chatName from Chat table
ChannelStartupService-->>Client: Returns chat data with correct chatName
Sequence diagram for Contact PaginationsequenceDiagram
participant Client
participant ChannelStartupService
participant PrismaRepository
Client->>ChannelStartupService: Calls findContacts endpoint with page and offset
ChannelStartupService->>PrismaRepository: Calls contact.findMany with take and skip parameters
PrismaRepository-->>ChannelStartupService: Returns paginated contact data
ChannelStartupService-->>Client: Returns paginated contact data
Updated class diagram for ChannelStartupServiceclassDiagram
class ChannelStartupService {
+findContacts(query: any): Promise<Contact[]>
+findChats(query: any): Promise<Chat[]>
}
class Contact {
id: string
remoteJid: string
pushName: string
chatName: string
profilePicUrl: string
updatedAt: Date
windowStart: Date
}
note for Contact "Added chatName attribute"
class Chat {
name: string
createdAt: Date
}
ChannelStartupService -- Contact : returns
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @pedro-php - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider adding validation to ensure that
page
andoffset
are positive integers. - It might be worth extracting the pagination logic into a separate helper function to improve readability.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
up |
1 similar comment
up |
Fix
Problema
Ao se utilizar o endpoint de findChat para encontrar o nome de um grupo, era retornado o pushname do último usuário que enviou uma mensagem no chat ao invés do nome do chat em si.
O que foi alterado?
Ao receber uma mensagem, o chatName não mais é sobrescrito com o pushname do remetente da mensagem em mensagens provindas de grupo. Também foi adicionado ao retorno do endpoint um parâmetro chatName, que retorna o chatname da tabela de Chats.
Resolução
Agora, ao se chamar o endpoint, um parâmetro extra chatName retorna o campo chatname da tabela de Chats, correspondente ao pushname do usuário em contatos e ao nome do grupo em grupos.
Feature
Problema
Em números com muitos contatos e chats, realizar a chamada à esses endpoints podia ser demorada e algumas vezes impossível.
O que foi alterado
Adicionada a possibilidade de paginar os endpoints de findChats e findContacts atráves dos parâmetros page e offset. No endpoint de findChats, foi adicionada diretamente à rawQuery, e no enddpoint findContacts, foi adicionada aos parâmetros take e skip do prisma.
Resolução
O usuário pode agora, opcionalmente, paginar os resultados de ambos os endpoints, aliviando a carga da requisição.
Summary by Sourcery
Improves the findChats and findContacts endpoints by adding pagination and fixing a bug where the findChat endpoint returned the wrong name for group chats.
New Features:
Bug Fixes: