Skip to content

Commit c5fe07c

Browse files
committed
Merge remote-tracking branch 'origin/release-1.9.0'
2 parents fe3dd5e + cc897fa commit c5fe07c

15 files changed

Lines changed: 433 additions & 15 deletions

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### 1.9.0
2+
3+
* Add parameter to taxon concept show API internal endpoint to trimmed response for the mobile app
4+
15
### 1.8.6
26

37
* Schedule rebuild job to run daily on staging

app/controllers/api/v1/taxon_concepts_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def show
3131
s = Species::ShowTaxonConceptSerializerCites
3232
end
3333
render :json => @taxon_concept,
34-
:serializer => s
34+
:serializer => s, :trimmed => params[:trimmed]
3535
end
3636

3737
protected

app/models/species/taxon_concept_prefix_matcher.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def initialize_query
7373
end
7474

7575
@query = @query.
76-
select('id, full_name, rank_name, name_status,
76+
select('id, full_name, rank_name, name_status, author_year,
7777
ARRAY_AGG_NOTNULL(
7878
DISTINCT CASE
7979
WHEN matched_name != full_name THEN matched_name ELSE NULL
@@ -85,7 +85,7 @@ def initialize_query
8585
rank_display_name_en, rank_display_name_es, rank_display_name_fr').
8686
where(type_of_match: types_of_match).
8787
group([
88-
:id, :full_name, :rank_name, :name_status, :rank_order,
88+
:id, :full_name, :rank_name, :name_status, :author_year, :rank_order,
8989
:rank_display_name_en, :rank_display_name_es, :rank_display_name_fr
9090
])
9191

app/serializers/species/autocomplete_taxon_concept_serializer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Species::AutocompleteTaxonConceptSerializer < ActiveModel::Serializer
2-
attributes :id, :full_name, :rank_name, :name_status, :matching_names
2+
attributes :id, :full_name, :author_year, :rank_name, :name_status, :matching_names
33

44
def rank_name
55
rank_with_locale = "rank_display_name_#{I18n.locale.to_s}"

app/serializers/species/cites_listing_change_serializer.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@ class Species::CitesListingChangeSerializer < Species::ListingChangeSerializer
33
:hash_full_note_en, :hash_display,
44
:nomenclature_note_en, :nomenclature_note_fr, :nomenclature_note_es
55

6+
def include_is_addition?
7+
return true unless @options[:trimmed]
8+
@options[:trimmed] == 'false'
9+
end
10+
11+
def include_nomenclature_note_fr?
12+
return true unless @options[:trimmed]
13+
@options[:trimmed] == 'false'
14+
end
15+
16+
def include_nomenclature_note_es?
17+
return true unless @options[:trimmed]
18+
@options[:trimmed] == 'false'
19+
end
20+
621
def change_type
722
if object.change_type_name == ChangeType::RESERVATION_WITHDRAWAL
823
"w"

app/serializers/species/cites_suspension_serializer.rb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,21 @@ class Species::CitesSuspensionSerializer < ActiveModel::Serializer
77
:start_notification
88

99
def geo_entity
10-
object['geo_entity_en']
10+
@options[:trimmed] == 'true' ? object['geo_entity_en'].slice('iso_code2') : object['geo_entity_en']
1111
end
1212

1313
def start_notification
14-
object['start_notification']
14+
@options[:trimmed] == 'true' ? object['start_notification'].except('date') : object['start_notification']
1515
end
16+
17+
def include_nomenclature_note_fr?
18+
return true unless @options[:trimmed]
19+
@options[:trimmed] == 'false'
20+
end
21+
22+
def include_nomenclature_note_es?
23+
return true unless @options[:trimmed]
24+
@options[:trimmed] == 'false'
25+
end
26+
1627
end

app/serializers/species/eu_decision_serializer.rb

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,48 @@ class Species::EuDecisionSerializer < ActiveModel::Serializer
1212
:private_url,
1313
:intersessional_decision_id
1414

15+
def include_nomenclature_note_fr?
16+
return true unless @options[:trimmed]
17+
@options[:trimmed] == 'false'
18+
end
19+
20+
def include_nomenclature_note_es?
21+
return true unless @options[:trimmed]
22+
@options[:trimmed] == 'false'
23+
end
24+
25+
def include_private_url?
26+
return true unless @options[:trimmed]
27+
@options[:trimmed] == 'false'
28+
end
29+
30+
def include_intersessional_decision_id?
31+
return true unless @options[:trimmed]
32+
@options[:trimmed] == 'false'
33+
end
34+
1535
def eu_decision_type
16-
object['eu_decision_type']
36+
@options[:trimmed] == 'true' ? object['eu_decision_type'].slice('name') : object['eu_decision_type']
1737
end
1838

1939
def srg_history
20-
object['srg_history']
40+
@options[:trimmed] == 'true' ? object['srg_history'].except('description') : object['srg_history']
2141
end
2242

2343
def geo_entity
24-
object['geo_entity_en']
44+
@options[:trimmed] == 'true' ? object['geo_entity_en'].slice('iso_code2') : object['geo_entity_en']
2545
end
2646

2747
def start_event
28-
object['start_event']
48+
@options[:trimmed] == 'true' ? object['start_event'].except('date') : object['start_event']
2949
end
3050

3151
def source
3252
object['source_en']
3353
end
3454

3555
def term
36-
object['term_en']
56+
@options[:trimmed] == 'true' ? object['term_en'].slice('name') : object['term_en']
3757
end
3858

3959
def private_url

app/serializers/species/eu_listing_change_serializer.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@ class Species::EuListingChangeSerializer < Species::ListingChangeSerializer
44
:hash_full_note_en, :hash_display,
55
:nomenclature_note_en, :nomenclature_note_fr, :nomenclature_note_es
66

7+
def include_change_type_class?
8+
return true unless @options[:trimmed]
9+
@options[:trimmed] == 'false'
10+
end
11+
12+
def include_nomenclature_note_fr?
13+
return true unless @options[:trimmed]
14+
@options[:trimmed] == 'false'
15+
end
16+
17+
def include_nomenclature_note_es?
18+
return true unless @options[:trimmed]
19+
@options[:trimmed] == 'false'
20+
end
21+
722
def change_type
823
if object.change_type_name == ChangeType::RESERVATION_WITHDRAWAL
924
"w"

app/serializers/species/quota_serializer.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,23 @@ class Species::QuotaSerializer < ActiveModel::Serializer
55
:geo_entity,
66
:unit
77

8+
def include_nomenclature_note_fr?
9+
return true unless @options[:trimmed]
10+
@options[:trimmed] == 'false'
11+
end
12+
13+
def include_nomenclature_note_es?
14+
return true unless @options[:trimmed]
15+
@options[:trimmed] == 'false'
16+
end
17+
18+
def include_publication_date_formatted?
19+
return true unless @options[:trimmed]
20+
@options[:trimmed] == 'false'
21+
end
22+
823
def geo_entity
9-
object['geo_entity_en']
24+
@options[:trimmed] == 'true' ? object['geo_entity_en'].slice('iso_code2') : object['geo_entity_en']
1025
end
1126

1227
def unit

app/serializers/species/show_taxon_concept_serializer.rb

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)