Commit 65d9149d by jay

2 new custom routes created by jenendar for search bar

1 parent a0e1c3b4
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch via NPM",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script",
"develop"
],
"skipFiles": [
"<node_internals>/**"
],
"console": "integratedTerminal"
}
]
}
\ No newline at end of file
{
"search.exclude": {
"**/node_modules": false
}
}
\ No newline at end of file
......@@ -191,9 +191,12 @@ module.exports = factories.createCoreController(
ctx.request.body.data.httpRequestEmailHeaders = JSON.stringify(
spretoOTP.spertoEmailResponse.headers
);
ctx.request.body.data.httpRequestEmailMethod = spretoOTP.spertoEmailResponse.config.method;
ctx.request.body.data.httpRequestEmailUrl = spretoOTP.spertoEmailResponse.config.url;
ctx.request.body.data.httpsRequestEmailBody = spretoOTP.spertoEmailResponse.config.data;
ctx.request.body.data.httpRequestEmailMethod =
spretoOTP.spertoEmailResponse.config.method;
ctx.request.body.data.httpRequestEmailUrl =
spretoOTP.spertoEmailResponse.config.url;
ctx.request.body.data.httpsRequestEmailBody =
spretoOTP.spertoEmailResponse.config.data;
ctx.request.body.data.httpResposneEmailBody = JSON.stringify(
spretoOTP.spertoEmailResponse.data
);
......@@ -201,16 +204,16 @@ module.exports = factories.createCoreController(
ctx.request.body.data.httpSMSRequestHeaders = JSON.stringify(
spretoOTP.spertoEmailResponse.headers
);
ctx.request.body.data.httpSMSRequestMethod = spretoOTP.spertoEmailResponse.config.method;
ctx.request.body.data.httpSMSRequestUrl = spretoOTP.spertoEmailResponse.config.url;
ctx.request.body.data.httpsSMSRequestBody
= spretoOTP.spertoEmailResponse.config.data;
ctx.request.body.data.httpSMSRequestMethod =
spretoOTP.spertoEmailResponse.config.method;
ctx.request.body.data.httpSMSRequestUrl =
spretoOTP.spertoEmailResponse.config.url;
ctx.request.body.data.httpsSMSRequestBody =
spretoOTP.spertoEmailResponse.config.data;
ctx.request.body.data.httpSMSResposneBody = JSON.stringify(
spretoOTP.spertoEmailResponse.data
);
ctx.request.body.data.thirdPartyApiError = false;
} catch (error) {
ctx.request.body.data.httpRequestEmailHeaders = JSON.stringify(
......@@ -252,5 +255,106 @@ module.exports = factories.createCoreController(
return await super.create(ctx);
}
},
async apartmentfilterConfiguration(ctx) {
const location = ctx.request.body.location;
const matchingTownshipID = await strapi.entityService.findMany(
"api::township.township",
{
filters: {
location: location,
},
}
);
// console.log("matchingTownshipID");
// console.log(matchingTownshipID);
let projectsId = [];
let projectType = [];
for (let j = 0; j < matchingTownshipID.length; j++) {
const townshipId = matchingTownshipID[j].id;
const matchingTownship = await strapi.entityService.findMany(
"api::township.township",
{
// populate:{
// projects:{
// fields: ["id"]
// }},
populate: ["projects", "projects.projectType"],
filters: {
id: townshipId,
},
}
);
for (let i = 0; i < matchingTownship[0].projects.length; i++) {
const element = matchingTownship[0].projects[i];
projectsId.push(element.id);
projectType.push(element.projectType);
}
}
function removeDuplicates(arr) {
return arr.filter((item, index) => arr.indexOf(item) === index);
}
const finalArray = removeDuplicates(projectType);
// const matchingProjects =
console.log(projectsId);
ctx.send({
ok: true,
projectType: finalArray,
message: "filterConfiguration caleed",
});
},
async bedroomfilterConfiguration(ctx) {
const location = ctx.request.body.location;
const projectType = ctx.request.body.projectType;
const matchingProjects = await strapi.entityService.findMany(
"api::project.project",
{
populate: ["configurations"],
filters: {
$and: [
{
location: location,
},
{
projectType: projectType,
},
],
},
}
);
let finalProjects = [];
let porjectConfiguration = [];
for (let j = 0; j < matchingProjects.length; j++) {
const individualProject = matchingProjects[j];
for (let i = 0; i < individualProject.configurations.length; i++) {
const element = individualProject.configurations[i].bedrooms;
porjectConfiguration.push(element);
}
}
function removeDuplicates(arr) {
return arr.filter((item, index) => arr.indexOf(item) === index);
}
const finalArray = removeDuplicates(porjectConfiguration);
// const matchingProjects =
ctx.send({
ok: true,
porjectConfiguration: finalArray,
message: "filterConfiguration caleed",
});
},
})
);
......@@ -7,6 +7,22 @@ const routes = {
config: {
// some configuration...
}
},
{
method: "POST",
path: "/end-users/apartment-filter-configuration",
handler: "api::end-user.end-user.apartmentfilterConfiguration",
config: {
// some configuration...
}
},
{
method: "POST",
path: "/end-users/bedroom-filter-configuration",
handler: "api::end-user.end-user.bedroomfilterConfiguration",
config: {
// some configuration...
}
}
]
};
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!