From dd766b340707e2323fab0c6cee139db98abd7bf3 Mon Sep 17 00:00:00 2001 From: Adam Coffman Date: Tue, 3 Oct 2023 11:15:29 -0500 Subject: [PATCH 1/3] adjust docker build workflow --- .github/workflows/publish_headless_docker.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/publish_headless_docker.yml b/.github/workflows/publish_headless_docker.yml index 8ba049a0f..c02998c54 100644 --- a/.github/workflows/publish_headless_docker.yml +++ b/.github/workflows/publish_headless_docker.yml @@ -32,8 +32,7 @@ jobs: - name: Build and push Docker image uses: docker/build-push-action@v5 with: - context: ./server - file: Dockerfile-headless + file: ./server/Dockerfile-headless push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From 4382300996060785df7d290cca02e55d63669130 Mon Sep 17 00:00:00 2001 From: Adam Coffman Date: Wed, 4 Oct 2023 11:26:41 -0500 Subject: [PATCH 2/3] Fix logic for determining if EIDs are identical when there are multiple therapies or phenotypes specified --- .../input_adaptors/evidence_item_input_adaptor.rb | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/server/app/models/input_adaptors/evidence_item_input_adaptor.rb b/server/app/models/input_adaptors/evidence_item_input_adaptor.rb index 207bc0557..7133f3b98 100644 --- a/server/app/models/input_adaptors/evidence_item_input_adaptor.rb +++ b/server/app/models/input_adaptors/evidence_item_input_adaptor.rb @@ -20,16 +20,11 @@ def self.check_input_for_errors(evidence_input_object: ) query_fields.delete(:phenotype_ids) eid_query = EvidenceItem.where(query_fields) - if fields.phenotype_ids.any? - eid_query = eid_query.joins(:phenotypes).where("phenotypes.id" => fields.phenotype_ids) - end - - if fields.therapy_ids.any? - eid_query = eid_query.joins(:therapies).where("therapies.id" => fields.therapy_ids) - end if eid = eid_query.first - errors << "Existing identical Evidence Item found: EID#{eid.id}" + if eid.therapy_ids.sort == fields.therapy_ids.sort && eid.phenotype_ids.sort == fields.phenotype_ids.sort + errors << "Existing identical Evidence Item found: EID#{eid.id}" + end end existing_phenotype_ids = Phenotype.where(id: fields.phenotype_ids).pluck(:id) From 5bbc2fdc5cf147b200d9c59273bea9ed77ecf176 Mon Sep 17 00:00:00 2001 From: Adam Coffman Date: Wed, 4 Oct 2023 11:38:27 -0500 Subject: [PATCH 3/3] display error message on duplicate ncit ids, add search --- server/app/admin/therapies_admin.rb | 4 ++++ server/app/models/therapy.rb | 2 ++ 2 files changed, 6 insertions(+) diff --git a/server/app/admin/therapies_admin.rb b/server/app/admin/therapies_admin.rb index e294639e6..5e91f688b 100644 --- a/server/app/admin/therapies_admin.rb +++ b/server/app/admin/therapies_admin.rb @@ -6,6 +6,10 @@ scope :all, default: true scope :without_ncit_id, -> { Therapy.where(ncit_id: nil) } + search do |q| + q ? collection.where("name ILIKE ? OR ncit_id ILIKE ?", "%#{q}%", "%#{q}%") : collection + end + # Customize the table columns shown on the index view. table do column :id diff --git a/server/app/models/therapy.rb b/server/app/models/therapy.rb index e1ce31e9b..2e03ee108 100644 --- a/server/app/models/therapy.rb +++ b/server/app/models/therapy.rb @@ -6,6 +6,8 @@ class Therapy < ApplicationRecord has_and_belongs_to_many :assertions has_and_belongs_to_many :therapy_aliases + validates :ncit_id, uniqueness: true + def self.url_for(ncit_id:) if ncit_id.nil? nil