Skip to content

Commit

Permalink
fix: 🐛 netwhat 이름을 찾도록 conditionalProjectName 추가
Browse files Browse the repository at this point in the history
- close #409
  • Loading branch information
niamu01 committed Dec 24, 2023
1 parent b3861a2 commit 4aadcdc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
11 changes: 11 additions & 0 deletions app/src/api/project/db/project.database.aggregate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}` }],
});
Expand Down
10 changes: 8 additions & 2 deletions app/src/dailyActivity/db/dailyActivity.database.dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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',
});
Expand Down

0 comments on commit 4aadcdc

Please sign in to comment.