diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d825bf94fa..341b3528ad 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,6 +21,11 @@ jobs: - name: Get the sgn repo uses: actions/checkout@v2 + + - name: Extract branch name + shell: bash + run: echo ::set-output name=branch::$(echo ${GITHUB_REF#refs/heads/}) + id: extract_branch - name: Get breedbase_dockerfile if: startsWith(steps.extract_branch.outputs.branch, 'feature/') || startsWith(steps.extract_branch.outputs.branch, 'bug/') @@ -154,4 +159,4 @@ jobs: run: /entrypoint.sh --nopatch t/selenium2/stock 2>/dev/null - name: Run selenium tests tools - run: /entrypoint.sh --nopatch t/selenium2/tools 2>/dev/null \ No newline at end of file + run: /entrypoint.sh --nopatch t/selenium2/tools 2>/dev/null diff --git a/lib/CXGN/BrAPI/v2/ObservationUnits.pm b/lib/CXGN/BrAPI/v2/ObservationUnits.pm index 185cc6b4ef..244ebc2430 100644 --- a/lib/CXGN/BrAPI/v2/ObservationUnits.pm +++ b/lib/CXGN/BrAPI/v2/ObservationUnits.pm @@ -45,6 +45,8 @@ sub search { my $level_code_arrayref = $params->{observationUnitLevelCode} || ($params->{observationUnitLevelCodes} || ()); my $levels_relation_arrayref = $params->{observationLevelRelationships} || (); my $levels_arrayref = $params->{observationLevels} || (); + my $reference_ids_arrayref = $params->{externalReferenceId} || $params->{externalReferenceID} || ($params->{externalReferenceIds} || $params->{externalReferenceIDs} || ()); + my $reference_sources_arrayref = $params->{externalReferenceSource} || ($params->{externalReferenceSources} || ()); my $additional_info_type_id = SGN::Model::Cvterm->get_cvterm_row($self->bcs_schema, 'phenotype_additional_info', 'phenotype_property')->cvterm_id(); @@ -93,6 +95,8 @@ sub search { # Order by plot_number, account for non-numeric plot numbers order_by=>'NULLIF(regexp_replace(plot_number, \'\D\', \'\', \'g\'), \'\')::int', observation_unit_names_list=>$observation_unit_names_list, + xref_id_list=>$reference_ids_arrayref, + xref_source_list=>$reference_sources_arrayref # phenotype_min_value=>$phenotype_min_value, # phenotype_max_value=>$phenotype_max_value, # exclude_phenotype_outlier=>$exclude_phenotype_outlier diff --git a/lib/CXGN/Phenotypes/Search/MaterializedViewTable.pm b/lib/CXGN/Phenotypes/Search/MaterializedViewTable.pm index 8ce76d5d93..4852e2e2f1 100644 --- a/lib/CXGN/Phenotypes/Search/MaterializedViewTable.pm +++ b/lib/CXGN/Phenotypes/Search/MaterializedViewTable.pm @@ -117,6 +117,16 @@ has 'observation_unit_names_list' => ( is => 'rw', ); +has 'xref_id_list' => ( + isa => 'ArrayRef[Str]|Undef', + is => 'rw', +); + +has 'xref_source_list' => ( + isa => 'ArrayRef[Str]|Undef', + is => 'rw', +); + has 'exclude_phenotype_outlier' => ( isa => 'Bool|Undef', is => 'ro', @@ -170,7 +180,16 @@ sub search { my $stock_lookup = CXGN::Stock::StockLookup->new({ schema => $schema} ); my %synonym_hash_lookup = %{$stock_lookup->get_synonym_hash_lookup()}; - my $select_clause = "SELECT observationunit_stock_id, observationunit_uniquename, observationunit_type_name, germplasm_uniquename, germplasm_stock_id, rep, block, plot_number, row_number, col_number, plant_number, is_a_control, notes, trial_id, trial_name, trial_description, plot_width, plot_length, field_size, field_trial_is_planned_to_be_genotyped, field_trial_is_planned_to_cross, breeding_program_id, breeding_program_name, breeding_program_description, year, design, location_id, planting_date, harvest_date, folder_id, folder_name, folder_description, seedlot_transaction, seedlot_stock_id, seedlot_uniquename, seedlot_current_weight_gram, seedlot_current_count, seedlot_box_name, available_germplasm_seedlots, treatments, observations, count(observationunit_stock_id) OVER() AS full_count FROM materialized_phenotype_jsonb_table "; + my $select_clause = "SELECT observationunit_stock_id, observationunit_uniquename, observationunit_type_name, germplasm_uniquename, germplasm_stock_id, rep, block, plot_number, row_number, col_number, plant_number, is_a_control, notes, trial_id, trial_name, trial_description, plot_width, plot_length, field_size, field_trial_is_planned_to_be_genotyped, field_trial_is_planned_to_cross, breeding_program_id, breeding_program_name, breeding_program_description, year, design, location_id, planting_date, harvest_date, folder_id, folder_name, folder_description, seedlot_transaction, seedlot_stock_id, seedlot_uniquename, seedlot_current_weight_gram, seedlot_current_count, seedlot_box_name, available_germplasm_seedlots, treatments, observations, count(observationunit_stock_id) OVER() AS full_count FROM materialized_phenotype_jsonb_table + LEFT JOIN ( + select stock.stock_id, array_agg(db.name)::text[] as xref_sources, array_agg(dbxref.accession)::text[] as xref_ids + from stock + join stock_dbxref sd on stock.stock_id = sd.stock_id + join dbxref on sd.dbxref_id = dbxref.dbxref_id + join db on dbxref.db_id = db.db_id + group by stock.stock_id + ) xref on xref.stock_id = materialized_phenotype_jsonb_table.observationunit_stock_id + "; my $order_clause = $self->order_by ? " ORDER BY ".$self->order_by : " ORDER BY trial_name, observationunit_uniquename"; my @where_clause; @@ -196,6 +215,12 @@ sub search { } elsif ($self->subplot_list && scalar(@{$self->subplot_list})>0) { my $subplot_sql = _sql_from_arrayref($self->subplot_list); push @where_clause, "observationunit_stock_id in ($subplot_sql)"; + } elsif ($self->xref_id_list && scalar(@{$self->xref_id_list})>0) { + my $xref_id_sql = _sql_from_arrayref($self->xref_id_list); + push @where_clause, "xref.xref_ids && '{$xref_id_sql}'"; + } elsif ($self->xref_source_list && scalar(@{$self->xref_source_list})>0) { + my $xref_source_sql = _sql_from_arrayref($self->xref_source_list); + push @where_clause, "xref.xref_sources && '{$xref_source_sql}'"; } if ($self->trial_list && scalar(@{$self->trial_list})>0) {