Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
acoffman committed Jan 30, 2025
2 parents 859f9f8 + 0c25c17 commit df5b698
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 11 deletions.
12 changes: 6 additions & 6 deletions server/app/graphql/types/queries/typeahead_queries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ def disease_typeahead(query_term:)
base_query = Disease.where(deprecated: false)
results = base_query.where("diseases.name ILIKE ?", "%#{query_term}%")
.or(base_query.where("diseases.doid ILIKE ?", "#{query_term}%"))
#.order("LENGTH(diseases.name) ASC")
.order("LENGTH(diseases.name) ASC")
.limit(10)
if results.size < 10
secondary_results = base_query.eager_load(:disease_aliases)
.where("disease_aliases.name ILIKE ?", "%#{query_term}%")
.where.not(id: results.select('id'))
#.order("LENGTH(diseases.name) ASC")
.order("LENGTH(diseases.name) ASC")
.distinct
.limit(10-results.size)
return results + secondary_results
Expand All @@ -100,7 +100,7 @@ def therapy_typeahead(query_term:)
base_query = Therapy.where(deprecated: false)
results = base_query.where("therapies.name ILIKE ?", "#{query_term}%")
.or(base_query.where("therapies.ncit_id ILIKE ?", "%#{query_term}%"))
#.order("LENGTH(therapies.name) ASC")
.order("LENGTH(therapies.name) ASC")
.limit(10)
if results.size < 10
secondary_results = base_query.where('therapies.name ILIKE ?', "%#{query_term}%")
Expand All @@ -110,7 +110,7 @@ def therapy_typeahead(query_term:)
tertiary_results = base_query.eager_load(:therapy_aliases)
.where("therapy_aliases.name ILIKE ?", "%#{query_term}%")
.where.not(id: results.select('id') + secondary_results.select('id'))
#.order("LENGTH(therapies.name) ASC")
.order("LENGTH(therapies.name) ASC")
.distinct
.limit(10-results.size)

Expand All @@ -131,14 +131,14 @@ def feature_typeahead(query_term:, feature_type: nil)
end

results = base_query.where('features.name ILIKE ?', "#{query_term}%")
#.order("LENGTH(features.name) ASC")
.order("LENGTH(features.name) ASC")
.limit(10)

if results.size < 10
secondary_results = base_query.eager_load(:feature_aliases)
.where("feature_aliases.name ILIKE ?", "#{query_term}%")
.where.not(id: results.select('id'))
#.order("LENGTH(features.name) ASC")
.order("LENGTH(features.name) ASC")
.distinct
.limit(10 - results.size)
return (results + secondary_results).uniq
Expand Down
11 changes: 11 additions & 0 deletions server/app/lib/link_adaptors/phenotype.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module LinkAdaptors
class Phenotype < Base
def display_name
obj.name
end

def base_path
"/phenotypes/#{obj.id}"
end
end
end
26 changes: 21 additions & 5 deletions server/app/models/frontend_router.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,16 @@ def url
def query_info
case id_type
when /genes?/
[
Feature.where(feature_instance_type: "Features::Gene"), :feature_instance_id,
[
Feature.where(feature_instance_type: "Features::Gene"), :id,
]
when /fusions?/
[
Feature.where(feature_instance_type: "Features::Fusion"), :id,
]
when /factors?/
[
Feature.where(feature_instance_type: "Features::Factor"), :id,
]
when /features?/
[ Feature, :id, ]
Expand All @@ -38,7 +46,7 @@ def query_info
when /entrez_id/
[ Features::Gene, :entrez_id ]
when /entrez_name/
[
[
Feature.where(feature_instance_type: "Features::Gene"), :name, -> { _1.upcase }
]
when /variant_groups?/
Expand All @@ -47,10 +55,18 @@ def query_info
[ Revision, :id ]
when /diseases?/
[ Disease, :id ]
when /doid/
[ Disease.where(deprecated: false), :doid, ]
when /drugs?/
[ Therapy, :id ]
when /therapies?/
[ Therapy, :id ]
when /ncit_id/
[ Therapy.where(deprecated: false), :ncit_id, ]
when /phenotypes?/
[ Phenotype, :id ]
when /hpo_id/
[ Phenotype, :hpo_id ]
when /assertions?/
[ Assertion, :id ]
when /sources?/
Expand All @@ -62,8 +78,8 @@ def query_info
when "AID"
[ Assertion, :id ]
when "GID"
[
Feature.where(feature_instance_type: "Features::Gene"), :feature_instance_id,
[
Feature.where(feature_instance_type: "Features::Gene"), :id,
]
when "FID"
[ Feature, :id ]
Expand Down

0 comments on commit df5b698

Please sign in to comment.