fix: simplify deleted query

This commit is contained in:
Mythie
2024-08-21 13:12:03 +10:00
parent d33bbe71e7
commit d2b99303f9
3 changed files with 19 additions and 132 deletions

View File

@ -197,9 +197,7 @@ type GetTeamCountsOption = {
};
const getTeamCounts = async (options: GetTeamCountsOption) => {
const { createdAt, teamId, teamEmail } = options;
const senderIds = options.senderIds ?? [];
const { createdAt, teamId, teamEmail, senderIds = [] } = options;
const userIdWhereClause: Prisma.DocumentWhereInput['userId'] =
senderIds.length > 0
@ -298,9 +296,13 @@ const getTeamCounts = async (options: GetTeamCountsOption) => {
_all: true,
},
where: {
userId: userIdWhereClause,
createdAt,
OR: [
{
teamId,
deletedAt: {
gte: DateTime.now().minus({ days: 30 }).startOf('day').toJSDate(),
},
},
{
status: ExtendedDocumentStatus.PENDING,
Recipient: {