Skip to content

Commit 5525941

Browse files
authored
Merge pull request #553 from contentstack/feature/CMG-566-test-stack
added code
2 parents 83bafb8 + 02e9cac commit 5525941

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

api/src/services/org.service.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import logger from "../utils/logger.js";
88
import { HTTP_TEXTS, HTTP_CODES } from "../constants/index.js";
99
import { ExceptionFunction } from "../utils/custom-errors.utils.js";
1010
import { BadRequestError } from "../utils/custom-errors.utils.js";
11+
import ProjectModelLowdb from "../models/project-lowdb.js";
1112

1213
/**
1314
* Retrieves all stacks based on the provided request.
@@ -38,7 +39,6 @@ const getAllStacks = async (req: Request): Promise<LoginServiceType> => {
3839
},
3940
})
4041
);
41-
// console.info(err, res);
4242
if (err) {
4343
logger.error(
4444
getLogMessage(
@@ -63,11 +63,20 @@ const getAllStacks = async (req: Request): Promise<LoginServiceType> => {
6363
);
6464
});
6565
}
66-
// const locale:any[]
67-
// const locale = await getStackLocal(token_payload, stacks);
66+
await ProjectModelLowdb?.read?.();
67+
const testStacks = ProjectModelLowdb?.chain?.get?.("projects")?.flatMap?.("test_stacks")?.value?.();
68+
if (testStacks?.length > 0) {
69+
const filterStacks = [];
70+
for (const stack of stacks ?? []) {
71+
const isPresent = testStacks?.find?.((testStack: any) => testStack?.stackUid === stack?.api_key);
72+
if (isPresent === undefined) {
73+
filterStacks?.push(stack);
74+
}
75+
}
76+
stacks = filterStacks;
77+
}
6878
return {
6979
data: {
70-
// stacks: locale,
7180
stacks,
7281
},
7382
status: res.status,

0 commit comments

Comments
 (0)