Class: Queries::TaxonName::Filter
- Includes:
- Concerns::Tags, Concerns::Users, Helpers
- Defined in:
- lib/queries/taxon_name/filter.rb
Overview
Instance Attribute Summary collapse
-
#ancestors ⇒ Object
- 'true' or 'false'
-
on initialize Ignored when taxon_name_id[].empty? Works as AND clause with descendants :(.
- #author ⇒ Object
-
#authors ⇒ Object
- 'true' or 'false'
-
on initialize whether the name has an author string, from any source, provided.
-
#citations ⇒ Object
Returns the value of attribute citations.
-
#combination_taxon_name_id ⇒ Array
Taxon_name_ids for which all Combinations will be returned.
-
#descendants ⇒ Object
- 'true' or 'false'
-
on initialize Ignored when taxon_name_id[].empty? Return descendants of parents as well.
-
#descendants_max_depth ⇒ Object
A positive integer indicating how many levels deep of descenants to retrieve.
-
#etymology ⇒ Object
- 'true' or 'false'
-
on initialize whether the name has etymology.
- #exact ⇒ Object
-
#leaves ⇒ Boolean?
TODO: inverse is duplicated in autocomplete.
- #name ⇒ Object
-
#nomenclature_code ⇒ String?
Accessor for attr :nomenclature_code, wrap with needed wildcards.
-
#nomenclature_group ⇒ String?
Accessor for attr :nomenclature_group, wrap with needed wildcards.
-
#not_specified ⇒ Object
Returns the value of attribute not_specified.
-
#otus ⇒ Object
- 'true' or 'false'
-
on initialize whether the name has an Otu.
-
#parent_id ⇒ Object
Return the taxon names with this/these parent_ids.
-
#project_id ⇒ Object
TODO: probably should be an array for API purposes.
-
#rank ⇒ Object
Returns the value of attribute rank.
- #sort ⇒ String?
- #taxon_name_author_ids ⇒ Array
- #taxon_name_author_ids_or ⇒ Boolean
- #taxon_name_classification ⇒ Object
-
#taxon_name_id ⇒ Object
Return the taxon name(s) with this/these ids.
-
#taxon_name_relationship ⇒ Object
Each entry must have a 'type' Each entry must have one (and only one) of 'subject_taxon_name_id' or 'object_taxon_name_id'.
- #taxon_name_relationship_type ⇒ Object
-
#taxon_name_type ⇒ String?
&taxon_name_type=<Protonym|Combination|Hybrid>.
-
#type_metadata ⇒ Object
- 'true' or 'false'
-
on initialize whether the name has TypeMaterial.
-
#updated_since ⇒ Object
TODO: deprecate for Queries::Concerns::User.
-
#validity ⇒ Object
- 'true' or 'false'
-
on initialize true if only valid, false if only invalid, nil if both.
-
#year ⇒ Object
Matches against cached_author_year.
Attributes inherited from Query
#dynamic_limit, #options, #query_string, #terms
Instance Method Summary collapse
- #all ⇒ ActiveRecord::Relation
-
#ancestor_facet ⇒ Object
A merge facet.
- #and_clauses ⇒ ActiveRecord::Relation
- #author_facet ⇒ Object
-
#authors_facet ⇒ Object
Scope.
- #base_query ⇒ Object
- #cached_name ⇒ Object
-
#citations_facet ⇒ Object
Scope.
- #combination_taxon_name_id_facet ⇒ Object
-
#descendant_facet ⇒ Object
A merge facet.
-
#initialize(params) ⇒ Filter
constructor
A new instance of Filter.
-
#leaves_facet ⇒ Object
Scope.
-
#matching_taxon_name_author_ids ⇒ Object
TODO: dry with Source, CollectingEvent , etc.
- #merge_clauses ⇒ Object
- #not_specified_facet ⇒ Object
- #order_clause(query) ⇒ Object
-
#otus_facet ⇒ Object
Scope.
- #parent_id_facet ⇒ Object
-
#rank_facet ⇒ Arel::Nodes::Grouping?
And clause.
- #table ⇒ Arel::Table
-
#taxon_name_classification_facet ⇒ Object
Scope.
- #taxon_name_id_facet ⇒ Object
-
#taxon_name_relationship_facet(hsh) ⇒ Object
Scope wrapped in descendant_facet!.
-
#taxon_name_relationship_type_facet ⇒ Object
Scope.
- #taxon_name_type_facet ⇒ Object
-
#type_metadata_facet ⇒ Object
Scope.
- #updated_since_facet ⇒ Object
- #validity_facet ⇒ Object
-
#with_etymology_facet ⇒ Object
Scope.
-
#with_nomenclature_code ⇒ Arel::Nodes::Grouping?
And clause.
-
#with_nomenclature_group ⇒ Arel::Nodes::Grouping?
And clause.
- #year_facet ⇒ Object
Methods included from Helpers
Methods inherited from Query
#alphabetic_strings, #alphanumeric_strings, #attribute_exact_facet, #autocomplete, #autocomplete_cached, #autocomplete_cached_wildcard_anywhere, #autocomplete_common_name_exact, #autocomplete_common_name_like, #autocomplete_exact_id, #autocomplete_exactly_named, #autocomplete_named, #autocomplete_ordered_wildcard_pieces_in_cached, #build_terms, #cached, #combine_or_clauses, #common_name_name, #common_name_table, #common_name_wild_pieces, #end_wildcard, #exactly_named, #fragments, #integers, #levenshtein_distance, #match_ordered_wildcard_pieces_in_cached, #match_wildcard_end_in_cached, #match_wildcard_in_cached, #named, #no_terms?, #only_ids, #only_integers?, #parent, #parent_child_join, #parent_child_where, #pieces, #result, #scope, #start_and_end_wildcard, #start_wildcard, #string_fragments, #wildcard_pieces, #wildcard_wrapped_integers, #wildcard_wrapped_years, #with_cached, #with_cached_like, #with_id, #with_project_id, #year_letter, #years
Constructor Details
#initialize(params) ⇒ Filter
Returns a new instance of Filter.
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/queries/taxon_name/filter.rb', line 164 def initialize(params) @author = params[:author] @authors = boolean_param(params, :authors ) @citations = params[:citations] @descendants = boolean_param(params,:descendants ) @descendants_max_depth = params[:descendants_max_depth] @ancestors = boolean_param(params,:ancestors ) @exact = boolean_param(params, :exact) @leaves = boolean_param(params, :leves) @name = params[:name] @not_specified = boolean_param(params, :not_specified) @nomenclature_code = params[:nomenclature_code] if !params[:nomenclature_code].nil? @nomenclature_group = params[:nomenclature_group] if !params[:nomenclature_group].nil? @rank = params[:rank] @otus = boolean_param(params, :otus) @etymology = boolean_param(params, :etymology) @project_id = params[:project_id] @taxon_name_classification = params[:taxon_name_classification] || [] @taxon_name_id = params[:taxon_name_id] @combination_taxon_name_id = params[:combination_taxon_name_id] @parent_id = params[:parent_id] || [] @sort = params[:sort] @taxon_name_relationship = params[:taxon_name_relationship] || [] @taxon_name_relationship_type = params[:taxon_name_relationship_type] || [] @taxon_name_type = params[:taxon_name_type] @type_metadata = boolean_param(params, :type_metadata) @updated_since = params[:updated_since].to_s @validity = boolean_param(params, :validity) @year = params[:year].to_s @taxon_name_author_ids = params[:taxon_name_author_ids].blank? ? [] : params[:taxon_name_author_ids] @taxon_name_author_ids_or = boolean_param(params, :taxon_name_author_ids_or) (params) set_user_dates(params) end |
Instance Attribute Details
#ancestors ⇒ Object
- 'true' or 'false'
-
on initialize
Ignored when taxon_name_id[].empty? Works as AND clause with descendants :(
66 67 68 |
# File 'lib/queries/taxon_name/filter.rb', line 66 def ancestors @ancestors end |
#author ⇒ Object
18 19 20 |
# File 'lib/queries/taxon_name/filter.rb', line 18 def @author end |
#authors ⇒ Object
- 'true' or 'false'
-
on initialize
whether the name has an author string, from any source, provided
108 109 110 |
# File 'lib/queries/taxon_name/filter.rb', line 108 def @authors end |
#citations ⇒ Object
Returns the value of attribute citations.
93 94 95 |
# File 'lib/queries/taxon_name/filter.rb', line 93 def citations @citations end |
#combination_taxon_name_id ⇒ Array
Returns taxon_name_ids for which all Combinations will be returned.
157 158 159 |
# File 'lib/queries/taxon_name/filter.rb', line 157 def combination_taxon_name_id @combination_taxon_name_id end |
#descendants ⇒ Object
- 'true' or 'false'
-
on initialize
Ignored when taxon_name_id[].empty? Return descendants of parents as well.
56 57 58 |
# File 'lib/queries/taxon_name/filter.rb', line 56 def descendants @descendants end |
#descendants_max_depth ⇒ Object
A positive integer indicating how many levels deep of descenants to retrieve.
Ignored when descentants is false/unspecified
61 62 63 |
# File 'lib/queries/taxon_name/filter.rb', line 61 def descendants_max_depth @descendants_max_depth end |
#etymology ⇒ Object
- 'true' or 'false'
-
on initialize
whether the name has etymology
103 104 105 |
# File 'lib/queries/taxon_name/filter.rb', line 103 def etymology @etymology end |
#exact ⇒ Object
27 28 29 |
# File 'lib/queries/taxon_name/filter.rb', line 27 def exact @exact end |
#leaves ⇒ Boolean?
TODO: inverse is duplicated in autocomplete
136 137 138 |
# File 'lib/queries/taxon_name/filter.rb', line 136 def leaves @leaves end |
#name ⇒ Object
14 15 16 |
# File 'lib/queries/taxon_name/filter.rb', line 14 def name @name end |
#nomenclature_code ⇒ String?
Returns accessor for attr :nomenclature_code, wrap with needed wildcards.
129 130 131 |
# File 'lib/queries/taxon_name/filter.rb', line 129 def nomenclature_code @nomenclature_code end |
#nomenclature_group ⇒ String?
Returns accessor for attr :nomenclature_group, wrap with needed wildcards.
125 126 127 |
# File 'lib/queries/taxon_name/filter.rb', line 125 def nomenclature_group @nomenclature_group end |
#not_specified ⇒ Object
Returns the value of attribute not_specified.
120 121 122 |
# File 'lib/queries/taxon_name/filter.rb', line 120 def not_specified @not_specified end |
#otus ⇒ Object
- 'true' or 'false'
-
on initialize
whether the name has an Otu
98 99 100 |
# File 'lib/queries/taxon_name/filter.rb', line 98 def otus @otus end |
#parent_id ⇒ Object
Return the taxon names with this/these parent_ids
51 52 53 |
# File 'lib/queries/taxon_name/filter.rb', line 51 def parent_id @parent_id end |
#project_id ⇒ Object
TODO: probably should be an array for API purposes. TODO: unify globally as to whether param belongs here, or at controller level.
88 89 90 |
# File 'lib/queries/taxon_name/filter.rb', line 88 def project_id @project_id end |
#rank ⇒ Object
Returns the value of attribute rank.
160 161 162 |
# File 'lib/queries/taxon_name/filter.rb', line 160 def rank @rank end |
#sort ⇒ String?
153 154 155 |
# File 'lib/queries/taxon_name/filter.rb', line 153 def sort @sort end |
#taxon_name_author_ids ⇒ Array
143 144 145 |
# File 'lib/queries/taxon_name/filter.rb', line 143 def @taxon_name_author_ids end |
#taxon_name_author_ids_or ⇒ Boolean
148 149 150 |
# File 'lib/queries/taxon_name/filter.rb', line 148 def @taxon_name_author_ids_or end |
#taxon_name_classification ⇒ Object
82 83 84 |
# File 'lib/queries/taxon_name/filter.rb', line 82 def taxon_name_classification @taxon_name_classification end |
#taxon_name_id ⇒ Object
Return the taxon name(s) with this/these ids
45 46 47 |
# File 'lib/queries/taxon_name/filter.rb', line 45 def taxon_name_id @taxon_name_id end |
#taxon_name_relationship ⇒ Object
Each entry must have a 'type' Each entry must have one (and only one) of 'subject_taxon_name_id' or 'object_taxon_name_id'
Return all taxon names in a relationship of a given type and in relation to a another name. For example, return all synonyms of Aus bus.
74 75 76 |
# File 'lib/queries/taxon_name/filter.rb', line 74 def taxon_name_relationship @taxon_name_relationship end |
#taxon_name_relationship_type ⇒ Object
78 79 80 |
# File 'lib/queries/taxon_name/filter.rb', line 78 def taxon_name_relationship_type @taxon_name_relationship_type end |
#taxon_name_type ⇒ String?
Returns &taxon_name_type=<Protonym|Combination|Hybrid>.
140 141 142 |
# File 'lib/queries/taxon_name/filter.rb', line 140 def taxon_name_type @taxon_name_type end |
#type_metadata ⇒ Object
- 'true' or 'false'
-
on initialize
whether the name has TypeMaterial
113 114 115 |
# File 'lib/queries/taxon_name/filter.rb', line 113 def @type_metadata end |
#updated_since ⇒ Object
TODO: deprecate for Queries::Concerns::User
34 35 36 |
# File 'lib/queries/taxon_name/filter.rb', line 34 def updated_since @updated_since end |
#validity ⇒ Object
- 'true' or 'false'
-
on initialize
true if only valid, false if only invalid, nil if both
39 40 41 |
# File 'lib/queries/taxon_name/filter.rb', line 39 def validity @validity end |
#year ⇒ Object
Matches against cached_author_year.
23 24 25 |
# File 'lib/queries/taxon_name/filter.rb', line 23 def year @year end |
Instance Method Details
#all ⇒ ActiveRecord::Relation
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 |
# File 'lib/queries/taxon_name/filter.rb', line 540 def all a = and_clauses b = merge_clauses q = nil if a && b q = b.where(a) elsif a q = ::TaxonName.where(a) elsif b q = b else q = ::TaxonName.all end q = q.where(project_id: project_id) if project_id q = order_clause(q) if sort q end |
#ancestor_facet ⇒ Object
A merge facet.
268 269 270 271 272 273 274 275 276 277 |
# File 'lib/queries/taxon_name/filter.rb', line 268 def ancestor_facet return nil if taxon_name_id.empty? || !(ancestors == true) ancestors_subquery = ::TaxonNameHierarchy.where( ::TaxonNameHierarchy.arel_table[:ancestor_id].eq(::TaxonName.arel_table[:id]).and( ::TaxonNameHierarchy.arel_table[:descendant_id].in(taxon_name_id)) ) ::TaxonName.where(ancestors_subquery.arel.exists) end |
#and_clauses ⇒ ActiveRecord::Relation
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 |
# File 'lib/queries/taxon_name/filter.rb', line 481 def and_clauses clauses = [] clauses += [ rank_facet, parent_id_facet, , cached_name, year_facet, updated_since_facet, validity_facet, taxon_name_id_facet, with_nomenclature_group, with_nomenclature_code, taxon_name_type_facet ].compact return nil if clauses.empty? a = clauses.shift clauses.each do |b| a = a.and(b) end a end |
#author_facet ⇒ Object
438 439 440 441 442 443 444 445 |
# File 'lib/queries/taxon_name/filter.rb', line 438 def return nil if .blank? if exact table[:cached_author_year].eq(.strip) else table[:cached_author_year].matches('%' + .strip.gsub(/\s/, '%') + '%') end end |
#authors_facet ⇒ Object
Returns Scope.
287 288 289 290 291 292 |
# File 'lib/queries/taxon_name/filter.rb', line 287 def return nil if .nil? ? ::TaxonName.where.not(cached_author_year: nil) : ::TaxonName.where(cached_author_year: nil) end |
#base_query ⇒ Object
206 207 208 |
# File 'lib/queries/taxon_name/filter.rb', line 206 def base_query ::TaxonName.select('taxon_names.*') end |
#cached_name ⇒ Object
424 425 426 427 428 429 430 431 |
# File 'lib/queries/taxon_name/filter.rb', line 424 def cached_name return nil if name.blank? if exact table[:cached].eq(name.strip) else table[:cached].matches('%' + name.strip.gsub(/\s+/, '%') + '%') end end |
#citations_facet ⇒ Object
Returns Scope.
385 386 387 388 389 390 391 392 393 394 395 396 |
# File 'lib/queries/taxon_name/filter.rb', line 385 def citations_facet return nil if citations.nil? citation_conditions = ::Citation.arel_table[:citation_object_id].eq(::TaxonName.arel_table[:id]).and( ::Citation.arel_table[:citation_object_type].eq('TaxonName')) if citations == 'without_origin_citation' citation_conditions = citation_conditions.and(::Citation.arel_table[:is_original].eq(true)) end ::TaxonName.where.not(::Citation.where(citation_conditions).arel.exists) end |
#combination_taxon_name_id_facet ⇒ Object
471 472 473 474 475 476 477 478 |
# File 'lib/queries/taxon_name/filter.rb', line 471 def combination_taxon_name_id_facet return nil if combination_taxon_name_id.empty? ::Combination.joins(:related_taxon_name_relationships) .where( taxon_name_relationships: { type: ::TAXON_NAME_RELATIONSHIP_COMBINATION_TYPES.values, subject_taxon_name_id: combination_taxon_name_id}).distinct end |
#descendant_facet ⇒ Object
A merge facet.
250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'lib/queries/taxon_name/filter.rb', line 250 def descendant_facet return nil if taxon_name_id.empty? || !(descendants == true) descendants_subquery = ::TaxonNameHierarchy.where( ::TaxonNameHierarchy.arel_table[:descendant_id].eq(::TaxonName.arel_table[:id]).and( ::TaxonNameHierarchy.arel_table[:ancestor_id].in(taxon_name_id)) ) unless descendants_max_depth.nil? || descendants_max_depth.to_i < 0 descendants_subquery = descendants_subquery.where(TaxonNameHierarchy.arel_table[:generations].lteq(descendants_max_depth.to_i)) end ::TaxonName.where(descendants_subquery.arel.exists) end |
#leaves_facet ⇒ Object
Returns Scope.
309 310 311 312 |
# File 'lib/queries/taxon_name/filter.rb', line 309 def leaves_facet return nil if leaves.nil? leaves ? ::TaxonName.leaves : ::TaxonName.not_leaves end |
#matching_taxon_name_author_ids ⇒ Object
TODO: dry with Source, CollectingEvent , etc.
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
# File 'lib/queries/taxon_name/filter.rb', line 342 def return nil if .empty? o = table r = ::Role.arel_table a = o.alias("a_") b = o.project(a[Arel.star]).from(a) c = r.alias('r1') b = b.join(c, Arel::Nodes::OuterJoin) .on( a[:id].eq(c[:role_object_id]) .and(c[:role_object_type].eq('TaxonName')) .and(c[:type].eq('TaxonNameAuthor')) ) e = c[:id].not_eq(nil) f = c[:person_id].eq_any() b = b.where(e.and(f)) b = b.group(a['id']) b = b.having(a['id'].count.eq(.length)) unless b = b.as('tn_z1_') ::TaxonName.joins(Arel::Nodes::InnerJoin.new(b, Arel::Nodes::On.new(b['id'].eq(o['id'])))) end |
#merge_clauses ⇒ Object
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 |
# File 'lib/queries/taxon_name/filter.rb', line 507 def merge_clauses clauses = [ combination_taxon_name_id_facet, ancestor_facet, , citations_facet, created_updated_facet, descendant_facet, keyword_id_facet, leaves_facet, , not_specified_facet, otus_facet, taxon_name_classification_facet, taxon_name_relationship_type_facet, , with_etymology_facet ].compact taxon_name_relationship.each do |hsh| clauses << taxon_name_relationship_facet(hsh) end return nil if clauses.empty? a = clauses.shift clauses.each do |b| a = a.merge(b) end a end |
#not_specified_facet ⇒ Object
236 237 238 239 240 241 242 243 244 245 |
# File 'lib/queries/taxon_name/filter.rb', line 236 def not_specified_facet return nil if not_specified.nil? if not_specified ::TaxonName.where(table[:cached].matches("%NOT SPECIFIED%").or( table[:cached_original_combination].matches("%NOT SPECIFIED%"))) else ::TaxonName.where(table[:cached].does_not_match("%NOT SPECIFIED%").and( table[:cached_original_combination].does_not_match("%NOT SPECIFIED%"))) end end |
#order_clause(query) ⇒ Object
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 |
# File 'lib/queries/taxon_name/filter.rb', line 561 def order_clause(query) case sort when 'alphabetical' ::TaxonName.select('*').from( query.order('taxon_names.cached'), :inner_query ) when 'classification' ::TaxonName.select('*').from( query .joins('INNER JOIN taxon_name_hierarchies ON taxon_names.id = taxon_name_hierarchies.descendant_id') .order('taxon_name_hierarchies.generations, taxon_name_hierarchies.ancestor_id, taxon_names.cached'), :inner_query ) else query end end |
#otus_facet ⇒ Object
Returns Scope.
280 281 282 283 284 |
# File 'lib/queries/taxon_name/filter.rb', line 280 def otus_facet return nil if otus.nil? subquery = ::Otu.where(::Otu.arel_table[:taxon_name_id].eq(::TaxonName.arel_table[:id])).arel.exists ::TaxonName.where(otus ? subquery : subquery.not) end |
#parent_id_facet ⇒ Object
433 434 435 436 |
# File 'lib/queries/taxon_name/filter.rb', line 433 def parent_id_facet return nil if parent_id.empty? table[:parent_id].eq_any(parent_id) end |
#rank_facet ⇒ Arel::Nodes::Grouping?
Returns and clause.
407 408 409 410 |
# File 'lib/queries/taxon_name/filter.rb', line 407 def rank_facet return nil if rank.blank? table[:rank_class].matches('%' + rank) # We don't wildcard end so that we can isolate to specific ranks and below end |
#table ⇒ Arel::Table
202 203 204 |
# File 'lib/queries/taxon_name/filter.rb', line 202 def table ::TaxonName.arel_table end |
#taxon_name_classification_facet ⇒ Object
Returns Scope.
330 331 332 333 334 335 336 337 338 339 |
# File 'lib/queries/taxon_name/filter.rb', line 330 def taxon_name_classification_facet return nil if taxon_name_classification.empty? ::TaxonName.where( ::TaxonNameClassification.where( ::TaxonNameClassification.arel_table[:taxon_name_id].eq(::TaxonName.arel_table[:id]).and( ::TaxonNameClassification.arel_table[:type].in(taxon_name_classification)) ).arel.exists ) end |
#taxon_name_id_facet ⇒ Object
466 467 468 469 |
# File 'lib/queries/taxon_name/filter.rb', line 466 def taxon_name_id_facet return nil if taxon_name_id.empty? || descendants || ancestors table[:id].eq_any(taxon_name_id) end |
#taxon_name_relationship_facet(hsh) ⇒ Object
Returns Scope wrapped in descendant_facet!.
316 317 318 319 320 321 322 323 324 325 326 327 |
# File 'lib/queries/taxon_name/filter.rb', line 316 def taxon_name_relationship_facet(hsh) param_key = hsh['subject_taxon_name_id'] ? 'subject_taxon_name_id' : 'object_taxon_name_id' join_key = hsh['subject_taxon_name_id'] ? 'object_taxon_name_id' : 'subject_taxon_name_id' ::TaxonName.where( ::TaxonNameRelationship.where( ::TaxonNameRelationship.arel_table[join_key].eq(::TaxonName.arel_table[:id]).and( ::TaxonNameRelationship.arel_table[param_key].eq(hsh[param_key])).and( ::TaxonNameRelationship.arel_table[:type].eq(hsh['type'])) ).arel.exists ) end |
#taxon_name_relationship_type_facet ⇒ Object
Returns Scope.
303 304 305 306 |
# File 'lib/queries/taxon_name/filter.rb', line 303 def taxon_name_relationship_type_facet return nil if taxon_name_relationship_type.empty? ::TaxonName.with_taxon_name_relationship(taxon_name_relationship_type) end |
#taxon_name_type_facet ⇒ Object
419 420 421 422 |
# File 'lib/queries/taxon_name/filter.rb', line 419 def taxon_name_type_facet return nil if taxon_name_type.blank? table[:type].eq(taxon_name_type) end |
#type_metadata_facet ⇒ Object
Returns Scope.
371 372 373 374 375 |
# File 'lib/queries/taxon_name/filter.rb', line 371 def return nil if .nil? subquery = ::TypeMaterial.where(::TypeMaterial.arel_table[:protonym_id].eq(::TaxonName.arel_table[:id])).arel.exists ::TaxonName.where( ? subquery : subquery.not) end |
#updated_since_facet ⇒ Object
452 453 454 455 |
# File 'lib/queries/taxon_name/filter.rb', line 452 def updated_since_facet return nil if updated_since.blank? table[:updated_at].gt(Date.parse(updated_since)) end |
#validity_facet ⇒ Object
457 458 459 460 461 462 463 464 |
# File 'lib/queries/taxon_name/filter.rb', line 457 def validity_facet return nil if validity.nil? if validity table[:id].eq(table[:cached_valid_taxon_name_id]) else table[:id].not_eq(table[:cached_valid_taxon_name_id]) end end |
#with_etymology_facet ⇒ Object
Returns Scope.
295 296 297 298 299 300 |
# File 'lib/queries/taxon_name/filter.rb', line 295 def with_etymology_facet return nil if etymology.nil? etymology ? ::TaxonName.where.not(etymology: nil) : ::TaxonName.where(etymology: nil) end |
#with_nomenclature_code ⇒ Arel::Nodes::Grouping?
Returns and clause.
414 415 416 417 |
# File 'lib/queries/taxon_name/filter.rb', line 414 def with_nomenclature_code return nil if nomenclature_code.nil? table[:rank_class].matches(nomenclature_code) end |
#with_nomenclature_group ⇒ Arel::Nodes::Grouping?
Returns and clause.
400 401 402 403 |
# File 'lib/queries/taxon_name/filter.rb', line 400 def with_nomenclature_group return nil if nomenclature_group.blank? table[:rank_class].matches(nomenclature_group) end |
#year_facet ⇒ Object
447 448 449 450 |
# File 'lib/queries/taxon_name/filter.rb', line 447 def year_facet return nil if year.blank? table[:cached_author_year].matches('%' + year + '%') end |