Description
I've noticed that getting Resource Bookings with Work Periods working not correctly. Getting data from ES has more issues than getting data from DB, so I've added this line https://github.com/topcoder-platform/taas-apis/blob/dev/src/services/ResourceBookingService.js#L475 to force getting data from DB instead of ES as temporary workoaround.
We have to remove this workaround and fix getting data from ES and from DB too.
DB query issues
To force fallback to DB I'm forcing error for ES https://github.com/topcoder-platform/taas-apis/blob/dev/src/services/ResourceBookingService.js#L475
-
Sorting works incorrectly with pagination, it sorts data only on one page, while it should sort data across all the pages and only after return data for the first page.
For example, I'm sorting by
workPeriods.userHandle
and get this data on the first pagehttps://api.topcoder-dev.com/v5/resourceBookings?fields=workPeriods.userHandle,workPeriods.startDate,id&perPage=3&workPeriods.startDate=2021-02-21&sortBy=workPeriods.userHandle&sortOrder=asc&page=1
:[ { "id": "539616c7-a7c8-49a9-96ba-564bf0c96b53", "workPeriods": [ { "userHandle": "Aditya65", "startDate": "2021-02-21" } ] }, { "id": "921b015f-dfcc-4aae-b6fb-ee42ea1ab7e1", "workPeriods": [ { "userHandle": "Gayathri_1994", "startDate": "2021-02-21" } ] }, { "id": "9a3f5b57-8114-475e-85a5-8886ec21319d", "workPeriods": [ { "userHandle": "SriV_1672", "startDate": "2021-02-21" } ] } ]
Now I get data for the second page
/resourceBookings?fields=workPeriods.userHandle,workPeriods.startDate,id&perPage=3&workPeriods.startDate=2021-02-21&sortBy=workPeriods.userHandle&sortOrder=asc&page=2
:[ { "id": "ffe446b3-6529-48a6-a5dd-fd46c52e0d92", "workPeriods": [ { "userHandle": "GunaK-TopCoder", "startDate": "2021-02-21" } ] }, { "id": "eb711194-cc6b-41a0-afe9-a6bd2ece1c1e", "workPeriods": [ { "userHandle": "nkumar2", "startDate": "2021-02-21" } ] }, { "id": "a460f911-a0f9-4a38-a509-dc2a492403cd", "workPeriods": [ { "userHandle": "nkumar2", "startDate": "2021-02-21" } ] } ]
You can see that on the second page we get which should be on the first page.
ES query issues
To get data from ES we have to remove throwing error https://github.com/topcoder-platform/taas-apis/blob/dev/src/services/ResourceBookingService.js#L475
-
Filter by
workPeriods.*
still returns RB records without WP.For example if I fitler by
workPeriods.startDate
I still RB without WPs. Request/resourceBookings?fields=workPeriods.userHandle,workPeriods.startDate,id&perPage=3&workPeriods.startDate=2021-02-21
returns the next output:[ { "workPeriods": [], "id": "fe467c86-4662-46c1-9935-babb8e7ffe38" }, { "workPeriods": [], "id": "eb162e04-21b5-42e5-883b-1dc9b3fe3875" }, { "workPeriods": [], "id": "cccdbcc0-9d16-447f-87fe-33f0652bcccb" } ]
But we should not get these RB, because they don't have WP with
startDate=2021-02-21
. -
After fixing it. Make sure that sorting by WP fields with pagination from ES also works good and we don't have the same issue like with DB.
General
- During working on this task carefully check from where the response comes from. It's very easy to miss that instead of ES data comes from DB, because our logic fallbacks to DB. So always check the log to make sure that data comes from ES when you are testing ES.
- Make sure that all the filtering, sorting, pagination works correctly when we get data from ES.
- Make sure that all the filtering, sorting, pagination works correctly when we get data from DB during fallback.