-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Corrige filtro de mensagens com OR dinâmico #1780
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
Corrige filtro de mensagens com OR dinâmico #1780
Conversation
…r remoteJid ou senderPn
Reviewer's GuideRefactors WhatsApp message filtering in Prisma queries to dynamically combine remoteJid and senderPn conditions using an OR operator while retaining existing AND filters. Class diagram for updated message filter parametersclassDiagram
class KeyFilters {
id: string
fromMe: boolean
remoteJid: string
senderPn: string
participants: string
}
Flow diagram for dynamic OR filtering in message queriesflowchart TD
A[Receive keyFilters input] --> B{Build Prisma where clause}
B --> C[Add AND filters: id, fromMe, participants]
B --> D[Add OR filters: remoteJid, senderPn]
C --> E[Execute count or findMany query]
D --> E
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 @anderecc - I've reviewed your changes - here's some feedback:
- The OR filter should be nested inside the AND array (e.g. AND: […, { OR: […] }]) to preserve the intended A AND (B OR C) logic rather than placing OR at the top level.
- Build the OR array dynamically by only adding objects when keyFilters.remoteJid/senderPn is defined, so you don’t include empty filter objects that could match everything unexpectedly.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The OR filter should be nested inside the AND array (e.g. AND: […, { OR: […] }]) to preserve the intended A AND (B OR C) logic rather than placing OR at the top level.
- Build the OR array dynamically by only adding objects when keyFilters.remoteJid/senderPn is defined, so you don’t include empty filter objects that could match everything unexpectedly.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
…r remoteJid ou senderPn
|
Please fix the lint with |
Adicionado operador OR em "prismaRepository.message.count" e "prismaRepository.message.findMany" para filtrar as mensagens de um contato por "remoteJid" ou "senderPn".
Essa atualização serve para ajudar a buscar as mensagens do cliente que vem com o campo "remoteJid" com @lid.
Essa atualização permite trazer os resultados mais corretos para o filtro de mensagem, sem deixar as mensagens com senderPn que deveriam ter o padrão @WhatsApp que vinha antes em remoteJid.
Essa atualização busca com o where da seguinte forma:
where: {
key: {
remoteJid: '',
senderPn: '',
},
}
Acredito que sirva para mais pessoas essa att, outra forma seria nem passar o senderPn no where e colocar direto no método de count ou findMany... Mas dessa forma acredito que fique melhor o uso...
Summary by Sourcery
Allow filtering messages by either remoteJid or senderPn by adding dynamic OR conditions to Prisma message queries
Enhancements: