tenders-exposed / elvis-ember

**el.vis** - a tool for visualising public (EU) tenders big data
https://talk.tenders.exposed
GNU Affero General Public License v3.0
8 stars 2 forks source link

Retrieve `winningBids` from separate endpoint #539

Open georgiana-b opened 4 years ago

georgiana-b commented 4 years ago

The list of winningBids was removed from the node, edge and cluster details payload (/networks/{networkID}/nodes/{nodeID}, /networks/{networkID}/edges/{edgeID}/ ) because it was slowing things down significantly for nodes with many tenders.

Instead I created 3 new endpoints where the bids can be retrieved in a paginated way to avoid long and heavy requests:

All the 3 endpoints support 2 parameters for pagination:

To load the first 10 results of a node, for example you can make the following request:

GET /networks/{networkID}/nodes/{nodeID}/bids?limit=10&page=1

Then to load the next 10 results you would do

GET /networks/{networkID}/nodes/{nodeID}/bids?limit=10&page=2

and so on until you retrieve all the results.

You can tell that you've reached the last page by the fact that the number of results is < limit. If you go past the page with the last set of results, on the next pages after that you will just get an empty array.

georgiana-b commented 4 years ago

@ca1yps0 I added some more details to the bid results, as we discussed.

So the paginated results on /node/{nodeID}/bids, edge/{edgeId}/bids /cluster/{clusterID}/bids now look like this:

{
  "page": "{number of the current page}",
  "resultsPerPage": "{current number of results to be returned per page}",
  "totalResults": "{total number of results}",
  "totalPages": "{number of pages with results}",
  "bids": [{array of bids exactly as they looked like before}]
}

Let me know if anything.

georgiana-b commented 4 years ago

We also decided to allow the user to set the limit for how many things to load on the page themselves, from a dropdown with 3 options: 5, 10 and 50.

The bids will come directly ordered by the amount from the backend.