I really can’t tell why the 5th test (“I can retrieve a full exercise log of any user by getting /api/exercise/log with a parameter of userId(_id). App will return the user object with added array log and count (total exercise count).”) times out. I tried different variations, but can’t get it to work. Please help!
Your code so far
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36.
try to get data from query like this let { userId,from,to,limit} = req.query;
after that you can get all users by that id and check if “from” is undefined if its not undefined
filter array with
data = data.filter((data) => {
let from_date = new Date(from);
let now_date = new Date(data['date'])
return from_date <= now_date
})
in this case data is exercises of user
you can filter the same array for “to” don’t forget to change this line return from_date <= now_date
Thanks, but the test about filtering is good. I have an issue with the second to last test. Here is the message I get:
I can retrieve a full exercise log of any user by getting /api/exercise/log with a parameter of userId(_id). App will return the user object with added array log and count (total exercise count). (Test timed out)
// tests completed
All other tests are passing. I also test it manually and it returns the right data. I guess there is a little timeout set in the test itself or maybe something else I don’t get from reading the instructions
I added a middleware to check all incoming requests when running the tests and everything seems fine. I even tried the urls manually and the app is responding as it should be.
Here you go. I guess it happens because I use MongoDB Atlas and it has a delay when fetching data from it. My best guess is that the test is somehow configured to check for a very little timeout.
Wow! I fixed the way I process dates and it passed. I can’t tell why the hell did it pass the test for adding exercise, but failed the one that reads. The problem was in my /api/exercise/add endpoint, which is not related to the issue I had…
Anyway thanks! However, I think the tests should be reviewed.
Too bad they closed it already. I’m failing this test as well even though my app literally returns the output described in the challenge. And on the closed bug they said “Unfortunately, the tests do not align perfectly with the challenge descriptions, and are extremely specific.” But if this isn’t being accepted as an actual bug, why not at least add wording to the challenge descriptions to to be as “extremely specific” as the tests? Why acknowledge the problem with ambiguity while doing nothing to address that ambiguity?
Please understand, the above issue was closed as it was unclear as to where the issue lay. This forum post being opened is exactly what I have been looking for to get a discussion going on the issue. I will reopen the issue.
As for many of the Backend challenges and projects, multiple issues are already open, and in discussion going about syncing the instructions with the tests, as well as improving the tests. We do apologise for the frustration caused.
Thank you. I also noticed that liked my tips on another user’s Curriculum Help post, now that I’ve finally gotten through the tests, so I will share a link to that post here in case it’s helpful to others in the meantime. Exercise Tracker works but not passing