From 4aadcdc97cc28fb969357ee13406dc85a5b1e160 Mon Sep 17 00:00:00 2001 From: niamu01 Date: Mon, 25 Dec 2023 05:39:44 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20:bug:=20netwhat=20=EC=9D=B4=EB=A6=84?= =?UTF-8?q?=EC=9D=84=20=EC=B0=BE=EB=8F=84=EB=A1=9D=20conditionalProjectNam?= =?UTF-8?q?e=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - close #409 --- app/src/api/project/db/project.database.aggregate.ts | 11 +++++++++++ .../dailyActivity/db/dailyActivity.database.dao.ts | 10 ++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/src/api/project/db/project.database.aggregate.ts b/app/src/api/project/db/project.database.aggregate.ts index b2e23ce7..31c5e802 100644 --- a/app/src/api/project/db/project.database.aggregate.ts +++ b/app/src/api/project/db/project.database.aggregate.ts @@ -24,6 +24,17 @@ export const conditionalProjectPreview = ( }, }); +export const conditionalProjectName = ( + projectIdField: string, + projectField: string, +) => ({ + $cond: { + if: { $eq: [`$${projectIdField}`, NETWHAT_PREVIEW.id] }, + then: NETWHAT_PREVIEW.name, + else: { $first: `$${projectField}.name` }, + }, +}); + export const concatProjectUrl = (projectIdField: string) => ({ $concat: [PROJECT_BASE_URL, '/', { $toString: `$${projectIdField}` }], }); diff --git a/app/src/dailyActivity/db/dailyActivity.database.dao.ts b/app/src/dailyActivity/db/dailyActivity.database.dao.ts index 2e9b8ac5..cb2eac2f 100644 --- a/app/src/dailyActivity/db/dailyActivity.database.dao.ts +++ b/app/src/dailyActivity/db/dailyActivity.database.dao.ts @@ -4,8 +4,12 @@ import type { Model } from 'mongoose'; import { lookupEvents } from 'src/api/event/db/event.database.aggregate'; import { events } from 'src/api/event/db/event.database.schema'; import { events_users } from 'src/api/eventsUser/db/eventsUser.database.schema'; -import { lookupProjects } from 'src/api/project/db/project.database.aggregate'; import { project } from 'src/api/project/db/project.database.schema'; + +import { + conditionalProjectName, + lookupProjects, +} from 'src/api/project/db/project.database.aggregate'; import { scale_team } from 'src/api/scaleTeam/db/scaleTeam.database.schema'; import { daily_logtimes } from 'src/dailyLogtime/db/dailyLogtime.database.schema'; import { @@ -170,7 +174,9 @@ export class DailyActivityDaoImpl implements DailyActivityDao { }, }, // todo: project collection 수정하고 s 삭제 - projectName: { $first: `$${project.name}s.name` }, + projectName: { + ...conditionalProjectName('team.projectId', `${project.name}s`), + }, beginAt: '$beginAt', filledAt: '$filledAt', });