Skip to content

Commit

Permalink
fix: removed unnecessary data from focus-area api
Browse files Browse the repository at this point in the history
  • Loading branch information
navneethkrish committed Dec 19, 2024
1 parent 9c0cb12 commit 0093b47
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions apps/web-api/src/focus-areas/focus-areas.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,27 @@ export class FocusAreasService {
async findAll(query) {
const { type } = query;
const result = await this.prisma.focusArea.findMany({
include: {
select: {
uid: true,
title: true,
description: true,
children: this.buildQueryByLevel(4, type, query), // level denotes depth of children.
...this.buildAncestorFocusAreasFilterByType(type, query)
},
orderBy: {
createdAt: "desc"
}
},
});
return result;
}

private buildQueryByLevel(level: number, type, query) {
if (level === 0) {
return {
include: {
select: {
uid: true,
title: true,
description: true,
children: true,
...this.buildAncestorFocusAreasFilterByType(type, query)
},
Expand All @@ -34,7 +40,10 @@ export class FocusAreasService {
};
}
return {
include: {
select: {
uid: true,
title: true,
description: true,
children: this.buildQueryByLevel(level - 1, type, query),
...this.buildAncestorFocusAreasFilterByType(type, query)
},
Expand Down

0 comments on commit 0093b47

Please sign in to comment.