@@ -10,6 +10,41 @@ class Species::ShowTaxonConceptSerializer < ActiveModel::Serializer
1010 has_many :taxon_concept_references , :serializer => Species ::ReferenceSerializer ,
1111 :key => :references
1212
13+ def include_parent_id?
14+ return true unless @options [ :trimmed ]
15+ @options [ :trimmed ] == 'false'
16+ end
17+
18+ def include_nomenclature_notification?
19+ return true unless @options [ :trimmed ]
20+ @options [ :trimmed ] == 'false'
21+ end
22+
23+ def include_subspecies?
24+ return true unless @options [ :trimmed ]
25+ @options [ :trimmed ] == 'false'
26+ end
27+
28+ def include_kingdom_name?
29+ return true unless @options [ :trimmed ]
30+ @options [ :trimmed ] == 'false'
31+ end
32+
33+ def include_species_name?
34+ return true unless @options [ :trimmed ]
35+ @options [ :trimmed ] == 'false'
36+ end
37+
38+ def include_rank_name?
39+ return true unless @options [ :trimmed ]
40+ @options [ :trimmed ] == 'false'
41+ end
42+
43+ def include_name_status?
44+ return true unless @options [ :trimmed ]
45+ @options [ :trimmed ] == 'false'
46+ end
47+
1348 def rank_name
1449 object . data [ 'rank_name' ]
1550 end
@@ -90,7 +125,14 @@ def distributions_with_tags_and_references
90125 end
91126
92127 def distributions
93- distributions_with_tags_and_references
128+ @options [ :trimmed ] == 'true' ? distributions_with_tags_and_references_trimmed : distributions_with_tags_and_references
129+ end
130+
131+ def distributions_with_tags_and_references_trimmed
132+ Distribution . from ( 'api_distributions_view distributions' ) .
133+ where ( taxon_concept_id : object . id ) .
134+ select ( "iso_code2, ARRAY_TO_STRING(tags, ',') AS tags_list" ) .
135+ order ( 'iso_code2' ) . all
94136 end
95137
96138 def subspecies
@@ -105,7 +147,7 @@ def standard_references
105147 end
106148
107149 def distribution_references
108- distributions_with_tags_and_references
150+ @options [ :trimmed ] == 'true' ? distributions_with_tags_and_references_trimmed : distributions_with_tags_and_references
109151 end
110152
111153 def cache_key
@@ -115,7 +157,8 @@ def cache_key
115157 object . updated_at ,
116158 object . dependents_updated_at ,
117159 object . m_taxon_concept . try ( :updated_at ) || "" ,
118- scope . current_user ? true : false
160+ scope . current_user ? true : false ,
161+ @options [ :trimmed ] == 'true' ? true : false
119162 ]
120163 Rails . logger . debug "CACHE KEY: #{ key . inspect } "
121164 key
0 commit comments