For the issue tracker project from quality assurance projects, my code passes all the test cases (excluding the functional tests) except the get request with filtering.
My source code for the get request (link for complete source code given below):
.get(async function (req, res){
let project = req.params.project;
let projectFromDb = await Project.findOne({name: project}).populate("issues", "-__v");
if (!projectFromDb) {
let newProject = new Project({
name: project
});
newProject = await newProject.save();
return res.json(newProject.issues);
}
console.log(project, req.query);
const issuesToSend = filterIssues(projectFromDb.issues, req.query);
return res.json(issuesToSend);
})
The filterIssues function code
function filterIssues(issues, conditions) {
function deepFilter(obj) {
let keys = Object.keys(conditions);
for (let key of keys)
if (conditions[key] != obj[key])
return false;
return true;
};
return issues.filter(deepFilter);
};
source code: https://replit.com/@itsmesv/boilerplate-project-issuetracker
Thanks in advance!!
EDIT:
The way I was filtering was slow and just noticed that i was getting timed out error. Fixed it and currently writing the fuctional tests.
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36
Challenge: Issue Tracker
Link to the challenge: