| for (inti = 0; i < 100; i++) { // Start at page 0 and increment each time until there are no more valid pages |
| JsonObjectjsonObject = httpUtils.urlRequestPOST(HttpUtils.URL_BASE + "/User/Search/GlobalName/" + i + "/", body); |
| |
| // Only continue looping if the result has a list of search results |
| if (jsonObject.has("Response") && jsonObject.getAsJsonObject("Response").getAsJsonArray("searchResults").size() != 0) { |
| JsonArrayjsonArray = jsonObject.getAsJsonObject("Response").getAsJsonArray("searchResults"); |
| |
| for (JsonElementjsonElement : jsonArray) { // Add all user info objects into one list |
| jsonObjects.add(jsonElement.getAsJsonObject()); |
| } |
| } else { |
| break; |
| } |
| } |
Paginating through the API automatically to get all the data at once is an inefficient way handle search. This is slow when searching for common terms in a username, i.e. "guardian"
Ideally, you should simply expose the pagination and allow developers to customize this a bit so that it can be performant
JavaDestinyAPI/src/main/java/net/dec4234/javadestinyapi/material/DestinyAPI.java
Lines 235 to 248 in bb65398
Paginating through the API automatically to get all the data at once is an inefficient way handle search. This is slow when searching for common terms in a username, i.e. "guardian"
Ideally, you should simply expose the pagination and allow developers to customize this a bit so that it can be performant