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

Analysis table fields 'analysisresults__name' and 'analysisresults__value' not filtering properly #63

Open
enmust opened this issue Jan 15, 2018 · 1 comment
Assignees

Comments

@urtson
Copy link

urtson commented Jan 16, 2018

Currently it is not possible to get desired results directly from 'analysis' table as it is an OR search from related table. It will search for analyses where zirconium is measured and analyses where any measured value is above 100.

Possible workaround is to use two queries:

  1. https://api.arendus.geokogud.info/analysis_results/?name__icontains=Zr&value__gt=100&fields=id
  2. https://api.arendus.geokogud.info/analysis/?analysisresults__id__in=1787,2228,...etc.
    If you get a single record from first query, use without __in lookup

Have to test it for speed, maybe not a good idea. The length of id list will be in thousands.

No idea yet how to do it in one query. Nested queries can be used in Django but it will make two queries anyway.
Another possibility is to create additional analysis summary table with all analyses and results inside.

All above goes also for #62

Also note:
https://api.arendus.geokogud.info/analysis_results/?paginate_by=30&page=1&order_by=-id&distinct=true&name__icontains=Zr&value__gt=100
it's not correct to use distinct=true here as it will eliminate possible distinct records with similar value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants