From 6430ccd96d1f7163ee903aab12db06cecaa01eba Mon Sep 17 00:00:00 2001 From: Akhil Reddy Date: Fri, 7 Feb 2025 11:16:49 +0530 Subject: [PATCH] schmea changes, removed notes --- src/notes/notes.controller.ts | 0 src/notes/notes.route.ts | 0 src/notes/notes.schema.ts | 19 ---------- src/notes/notes.service.ts | 0 src/notification/notification.service.ts | 48 ++++++++++++++++++++++++ src/rts/rts.service.ts | 2 + 6 files changed, 50 insertions(+), 19 deletions(-) delete mode 100644 src/notes/notes.controller.ts delete mode 100644 src/notes/notes.route.ts delete mode 100644 src/notes/notes.schema.ts delete mode 100644 src/notes/notes.service.ts diff --git a/src/notes/notes.controller.ts b/src/notes/notes.controller.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/notes/notes.route.ts b/src/notes/notes.route.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/notes/notes.schema.ts b/src/notes/notes.schema.ts deleted file mode 100644 index dd4fec0..0000000 --- a/src/notes/notes.schema.ts +++ /dev/null @@ -1,19 +0,0 @@ -import mongoose from "mongoose"; - -const noteSchema = new mongoose.Schema({ - resourceId: { - type: mongoose.Types.ObjectId, - required: true, - }, - content: { - type: String, - required: true, - }, - createdAt: Date, - createdBy: { - type: mongoose.Types.ObjectId, - ref: "user", - }, -}); - -export const noteModel = mongoose.model("note", noteSchema); diff --git a/src/notes/notes.service.ts b/src/notes/notes.service.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/notification/notification.service.ts b/src/notification/notification.service.ts index a5e85a2..ff721c3 100644 --- a/src/notification/notification.service.ts +++ b/src/notification/notification.service.ts @@ -31,6 +31,54 @@ export async function listNotifications( const notifications = await notificationModel.aggregate([ { $match: { $and: [{ tenantId: tenantId }, ...filterObj] } }, + { + $lookup: { + from: "organizations", + localField: "county", + foreignField: "_id", + as: "countyRec", + }, + }, + { + $lookup: { + from: "organizations", + localField: "client", + foreignField: "_id", + as: "clientRec", + }, + }, + { + $project: { + _id: 1, + pid: 1, + statusPipeline: 1, + createdAt: 1, + county: { + $let: { + vars: { county: { $arrayElemAt: ["$countyRec", 0] } }, + in: { + _id: "$$county._id", + pid: "$$county.pid", + name: "$$county.name", + type: "$$county.type", + avatar: "$$county.avatar", + }, + }, + }, + client: { + $let: { + vars: { client: { $arrayElemAt: ["$clientRec", 0] } }, + in: { + _id: "$$client._id", + pid: "$$client.pid", + name: "$$client.name", + type: "$$client.type", + avatar: "$$client.avatar", + }, + }, + }, + }, + }, { $facet: { metadata: [{ $count: "count" }], diff --git a/src/rts/rts.service.ts b/src/rts/rts.service.ts index 5eab2e7..f3f4f7e 100644 --- a/src/rts/rts.service.ts +++ b/src/rts/rts.service.ts @@ -96,6 +96,7 @@ export async function listRts(params: PageQueryParams, tenantId: string) { pid: "$$county.pid", name: "$$county.name", type: "$$county.type", + avatar: "$$county.avatar", }, }, }, @@ -107,6 +108,7 @@ export async function listRts(params: PageQueryParams, tenantId: string) { pid: "$$client.pid", name: "$$client.name", type: "$$client.type", + avatar: "$$client.avatar", }, }, },