feat: add tagging alerts and sorting on tags
This commit is contained in:
@@ -48,6 +48,7 @@ export async function updateProcessed(
|
||||
content: msg,
|
||||
},
|
||||
permitId,
|
||||
"processed",
|
||||
user
|
||||
);
|
||||
}
|
||||
@@ -70,6 +71,25 @@ export async function listProcessedPermits(
|
||||
filterObj.push({ client: new mongoose.Types.ObjectId(user.orgId) });
|
||||
}
|
||||
|
||||
let taggedFilter = [];
|
||||
if (sortObj.taggedUsers) {
|
||||
taggedFilter = [
|
||||
{
|
||||
$addFields: {
|
||||
taggedUsers: {
|
||||
$filter: {
|
||||
input: "$taggedUsers",
|
||||
as: "user",
|
||||
cond: { $eq: ["$$user.userId", user.userId] },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{ $match: { "taggedUsers.0": { $exists: true } } },
|
||||
{ $sort: { "taggedUsers.taggedAt": sortObj.taggedUsers } },
|
||||
];
|
||||
}
|
||||
|
||||
const pipeline: any = [
|
||||
{
|
||||
$match: { $and: [{ tenantId: user.tenantId }, ...filterObj] },
|
||||
@@ -91,6 +111,7 @@ export async function listProcessedPermits(
|
||||
|
||||
pipeline.push(
|
||||
...[
|
||||
...taggedFilter,
|
||||
{
|
||||
$lookup: {
|
||||
from: "users",
|
||||
|
||||
Reference in New Issue
Block a user