BioplatformsAustralia / bpaotu

OTU database access for the Australian Microbiome
GNU Affero General Public License v3.0
5 stars 1 forks source link

Sample search initiated before trait and taxonomy options have been fetched. #231

Open hou098 opened 2 years ago

hou098 commented 2 years ago

This is due to

export class SearchResultsTable extends React.Component<any> {

public componentDidMount() {
    if (isEmpty(this.props.results.data)) {
      this.props.search()
    }
  }

see https://github.com/BioplatformsAustralia/bpaotu/blob/9248eae9f21ec2145283725ac9b22b9c4296de97/frontend/src/components/search_results_table.tsx#L43

runserver_1     | 172.18.0.1 - - [08/Aug/2022 13:05:13] "GET /private/api/v1/config HTTP/1.1" 200 -
runserver_1     | 172.18.0.1 - - [08/Aug/2022 13:05:13] "GET /private/api/v1/user/check_permissions HTTP/1.1" 200 -
runserver_1     | 172.18.0.1 - - [08/Aug/2022 13:05:14] "GET /private/api/v1/reference-data-options HTTP/1.1" 200 -
runserver_1     | 172.18.0.1 - - [08/Aug/2022 13:05:14] "POST /private/api/v1/search HTTP/1.1" 200 -
runserver_1     | 172.18.0.1 - - [08/Aug/2022 13:05:14] "GET /private/api/v1/trait-options?amplicon=%7B%22value%22:3,%22operator%22:%22is%22%7D HTTP/1.1" 200 -
runserver_1     | 172.18.0.1 - - [08/Aug/2022 13:05:14] "GET /private/api/v1/taxonomy-options?amplicon=%7B%22value%22:3,%22operator%22:%22is%22%7D&selected=[%7B%22value%22:%22%22%7D,%7B%22value%22:%22%22%7D,%7B%22value%22:%22%22%7D,%7B%22value%22:%22%22%7D,%7B%22value%22:%22%22%7D,%7B%22value%22:%22%22%7D,%7B%22value%22:%22%22%7D,%7B%22value%22:%22%22%7D,%7B%22value%22:%22%22%7D]&trait=%7B%22value%22:%22%22,%22operator%22:%22is%22%7D HTTP/1.1" 200 -
runserver_1     | 172.18.0.1 - - [08/Aug/2022 13:05:14] "GET /private/api/v1/taxonomy-options?amplicon=%7B%22value%22:3,%22operator%22:%22is%22%7D&selected=[%7B%22value%22:8,%22operator%22:%22is%22%7D,%7B%22value%22:%22%22%7D,%7B%22value%22:%22%22%7D,%7B%22value%22:%22%22%7D,%7B%22value%22:%22%22%7D,%7B%22value%22:%22%22%7D,%7B%22value%22:%22%22%7D,%7B%22value%22:%22%22%7D,%7B%22value%22:%22%22%7D]&trait=%7B%22value%22:%22%22,%22operator%22:%22is%22%7D HTTP/1.1" 200 -
runserver_1     | 172.18.0.1 - - [08/Aug/2022 13:05:14] "GET /private/api/v1/taxonomy-options?amplicon=%7B%22value%22:3,%22operator%22:%22is%22%7D&selected=[%7B%22value%22:8,%22operator%22:%22is%22%7D,%7B%22value%22:%22%22%7D,%7B%22value%22:%22%22%7D,%7B%22value%22:%22%22%7D,%7B%22value%22:%22%22%7D,%7B%22value%22:%22%22%7D,%7B%22value%22:%22%22%7D,%7B%22value%22:%22%22%7D,%7B%22value%22:%22%22%7D]&trait=%7B%22value%22:%22%22,%22operator%22:%22is%22%7D HTTP/1.1" 200 -
runserver_1     | 172.18.0.1 - - [08/Aug/2022 13:05:15] "GET /private/api/v1/contextual-fields HTTP/1.1" 200 -

In this case the search is run with

 {"amplicon_filter":{"value":"","operator":"is"},"trait_filter":{"value":"","operator":"is"},"taxonomy_filters":[{"value":"","operator":"is"},{"value":"","operator":"is"},{"value":"","operator":"is"},{"value":"","operator":"is"},{"value":"","operator":"is"},{"value":"","operator":"is"},{"value":"","operator":"is"},{"value":"","operator":"is"},{"value":"","operator":"is"}],"contextual_filters":{"environment":null,"mode":"and","filters":[]}}

so it's not filtering on anything, not even amplicon or taxonomy, so the results are completely bogus.

Short term fix is probably just to get rid of componentDidMount() and let people click the "search" button to see the results. They're going to do this anyway, so there's no point in filling the table with an initial set of sample Ids, especially since they don't relate to any of the selected taxonomy, trait or amplicon options.

search needs to be delayed until we have all the taxonomy and trait options or we will end up fetching the wrong samples

hou098 commented 2 years ago

Applied short-term fix above in dddf396935e20b04c34d313b2fce3a44a688b4d1

hou098 commented 2 years ago

Ameliorated by traits fetching fix in https://github.com/BioplatformsAustralia/bpaotu/commit/4c5140f1d1c9114ade6af63b8a07096d862adabe