Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix erroneous pagination endpoints that use study filters #445

Open
znatty22 opened this issue Sep 20, 2018 · 0 comments
Open

Fix erroneous pagination endpoints that use study filters #445

znatty22 opened this issue Sep 20, 2018 · 0 comments
Labels
bug Something isn't working

Comments

@znatty22
Copy link
Member

znatty22 commented Sep 20, 2018

We are running into an issue we've had before #437. Some pagination endpoints, when called with a study filter parameter, return a number of results which does not match the total field in the json response.

This happens because certain queries (mostly when we are joining across multiple tables) return duplicate results from postgres. SqlAlchemy is smart about this and filters out the duplicates before returning the results. Our total field reflects the # of results returned by postgres and the actual length of results in the response document contains what comes out of sqlalchemy processing.

To fix this we need to add a sqlalchemy group_by call to the study filter param query:

if study_id:
            q = (q.join(SequencingCenter.biospecimens)
                 .join(Biospecimen.participant)
                 .filter(Participant.study_id == study_id)
                 .group_by(SequencingCenter.kf_id))

Currently, we know this is happening with the /sequencing-centers pagination endpoint, but could be happening with others as well. We need to fix sequencing centers and then check/fix all other pagination endpoints to ensure we eliminate this issue across the board.

@znatty22 znatty22 added the bug Something isn't working label Sep 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant