Repository navigation
[BI-3062] Replace simpleSearch usages for searchInternal to support >65k use cases - #578
Conversation
…rt full responses - Additionally fix some broken use cases in BrAPIGermplasmDAO
| * In this example, W should be a BrAPIGermplasmSearchRequest | ||
| * @return The full BrAPIResponse object from a completed BrAPI search request | ||
| */ | ||
| private <T extends BrAPIResponse<U>, U extends BrAPIResponseResult<V>, V, W extends BrAPISearchRequestParametersPaging> T searchInternalReturnResponse(Function<W, ApiResponse<Pair<Optional<T>, Optional<BrAPIAcceptedSearchResponse>>>> searchMethod, |
There was a problem hiding this comment.
This method is really where to start with this PR @humsika. Everything that was changed pretty much calls this method ultimately.
| if (!responsePagination.getCurrentPage().equals(requestPageNumber) || !responsePagination.getPageSize().equals(requestPageSize)) { | ||
| throw new InternalServerException("Page number and/or page size do not match between BrAPI search request and response"); | ||
| } | ||
| boolean pageThru = (searchBody.getPage() == null || searchBody.getPage() == 0) && (searchBody.getPageSize() == null || searchBody.getPageSize() == 0); |
There was a problem hiding this comment.
When the BrAPI server answers a paged search with 202 (async), does this still return the page we asked for? In the async branch, searchGetResponse seems to always poll with currentPage = 0 and the config pageSize (1000), so searchBody.getPage()/getPageSize() look like they’re ignored. Before this PR, simpleSearch threw on a 202, so this case used to fail loudly.
For example: an experimental collaborator with 4 or more authorized experiments opens page 2 (pageSize 50) of the Experiments table. searchTrials sends programDbIds plus 4 or more trialDbIds, which should push ProdServer’s SearchService past the 5-parameter threshold and return 202. Would that come back as page 0 with 1000 rows? Study searches by trialDbIds look like they’d take the same path.
Is that expected, or should the requested page and pageSize be passed through when pageThru is false?
There was a problem hiding this comment.
I corrected the code to account for this. Now if pageThru is true the page will be set to 0, and the pageSize will be set off of the code earlier in the method (if pageThru is true pageSize = 65k).
Otherwise, it will use the page and pagesize from the request, and should not activate the pageThru code.
I thought about making an integration test, but in general, I want us to stray from activating the async code as I think it is likely to be removed in the future. The use cases you've described are unlikely to occur, as there aren't many experimental collaboration use cases, but I did load in 11 experiments, set them all with the same exp collaborator user, logged in as that user, and was able to page thru to the second page.
I had to add some extra code to the prod server to ensure this would work, here. So, if you want to test that scenario, you can, but I think it's a bit overkill.
Description
Story: BI-3062
searchInternalinBrAPIDAOUtilwas modified to fulfill the main requirement for simple search, was to do all of the filtering/sorting/pagination on the BrAPI side, returning the full response from BrAPI to be processed by BI instead of just the list of data. All old callers of this method now point to this new version of this method, but instead of utilizing the BrAPI response the list data is derived from the response so those callers can process the way they did before. The new implementation,searchInternalFullResponse()should satisfy the simpleSearch and old search callers expectations.sendPaging, passed through to the final search method. I found this naming pretty confusing, considering I would expect sendPaging to mean you sent paging info to the server and it responded accordingly. Instead, this boolean was being used to page through all of the data for a given search request so that bi-api could get all of the data from the brapi server in one request. Because of this, the variable has been renamed topageThru. IfpageThruis true, all of the data found in the search request is paged through and returned in full to the BrAPI server.Dependencies
Testing
Regression of the following features:
Checklist: