Skip to content

Commit ad4d440

Browse files
committed
Add GTDB accession as name entrypoint
1 parent fbd8940 commit ad4d440

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

app/controllers/application_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ApplicationController < ActionController::Base
1313
],
1414
authors: [Author, %i[given family], {}],
1515
names: [
16-
Name, %i[name corrigendum_from],
16+
Name, %i[name corrigendum_from gtdb_accession],
1717
{
1818
# TODO
1919
# This is ready to work, but it could return too much "trash", so
@@ -90,7 +90,7 @@ def short_link
9090
name = Name.where(id: $2).first or not_found
9191
redirect_to(name_path(name, par))
9292
when /\A(n:)?([a-z_\. ]+)\z/i
93-
name = Name.find_by_variants($2.gsub('_', ' ')) or not_found
93+
name = Name.find_by_variants($2) or not_found
9494
redirect_to(name_path(name, par))
9595
when /\A(r:.+)\z/i
9696
list = Register.where(accession: $1).first or not_found

app/models/name.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,10 @@ class << self
143143
def find_variants(name)
144144
name = name.strip.downcase.gsub(/^candidatus /, '')
145145
vars = [name, "candidatus #{name}"]
146+
vars += vars.map { |i| i.gsub(/_+/, ' ') }
146147
Name.where('LOWER(name) IN (?, ?)', *vars)
147148
.or(Name.where('LOWER(corrigendum_from) IN (?, ?)', *vars))
149+
.or(Name.where('LOWER(gtdb_accession) IN (?, ?)', *vars))
148150
.or(Name.where(
149151
id: Pseudonym.where('LOWER(pseudonym) IN (?, ?)', *vars)
150152
.pluck(:name_id)

0 commit comments

Comments
 (0)