From 69c8f245231c848da89ec07b8b07730c6a6771fc Mon Sep 17 00:00:00 2001 From: roshan-mathewtech Date: Fri, 5 Aug 2022 18:41:37 +0100 Subject: [PATCH 01/15] Add mobile api endpoint serializers --- .../api/v1/taxon_concepts_controller.rb | 4 +- .../show_mobile_taxon_concept_serializer.rb | 135 ++++++++++++++++++ ...w_mobile_taxon_concept_serializer_cites.rb | 21 +++ ...how_mobile_taxon_concept_serializer_cms.rb | 70 +++++++++ 4 files changed, 228 insertions(+), 2 deletions(-) create mode 100644 app/serializers/species/mobile/show_mobile_taxon_concept_serializer.rb create mode 100644 app/serializers/species/mobile/show_mobile_taxon_concept_serializer_cites.rb create mode 100644 app/serializers/species/mobile/show_mobile_taxon_concept_serializer_cms.rb diff --git a/app/controllers/api/v1/taxon_concepts_controller.rb b/app/controllers/api/v1/taxon_concepts_controller.rb index aa7350f132..0c8dfb425a 100644 --- a/app/controllers/api/v1/taxon_concepts_controller.rb +++ b/app/controllers/api/v1/taxon_concepts_controller.rb @@ -26,9 +26,9 @@ def show :cites_suspensions => :geo_entity). includes(:taxonomy).find(params[:id]) if @taxon_concept.taxonomy.name == Taxonomy::CMS - s = Species::ShowTaxonConceptSerializerCms + s = params[:mobile].present? ? Species::Mobile::ShowMobileTaxonConceptSerializerCms : Species::ShowTaxonConceptSerializerCms else - s = Species::ShowTaxonConceptSerializerCites + s = params[:mobile].present? ? Species::Mobile::ShowMobileTaxonConceptSerializerCites : Species::ShowTaxonConceptSerializerCites end render :json => @taxon_concept, :serializer => s diff --git a/app/serializers/species/mobile/show_mobile_taxon_concept_serializer.rb b/app/serializers/species/mobile/show_mobile_taxon_concept_serializer.rb new file mode 100644 index 0000000000..cab15577d6 --- /dev/null +++ b/app/serializers/species/mobile/show_mobile_taxon_concept_serializer.rb @@ -0,0 +1,135 @@ +class Species::Mobile::ShowMobileTaxonConceptSerializer < ActiveModel::Serializer + cached + root 'taxon_concept' + attributes :id, :parent_id, :full_name, :author_year, + :common_names, :distributions, :subspecies, + :taxonomy, :kingdom_name, :phylum_name, :order_name, :class_name, :family_name, + :genus_name, :species_name, :rank_name, :name_status, :nomenclature_note_en, :nomenclature_notification + + has_many :synonyms, :serializer => Species::SynonymSerializer + + + def rank_name + object.data['rank_name'] + end + + def kingdom_name + object.data['kingdom_name'] + end + + def phylum_name + object.data['phylum_name'] + end + + def class_name + object.data['class_name'] + end + + def order_name + object.data['order_name'] + end + + def family_name + object.data['family_name'] + end + + def genus_name + object.data['genus_name'] + end + + def species_name + object.data['species_name'] + end + + def taxonomy + object.taxonomy.name.downcase + end + + def synonyms + object.synonyms. + order("full_name") + end + + def object_and_children + [object.id] + object.children.pluck(:id) + end + + def ancestors + [ + object.data['kingdom_id'], object.data['phylum_id'], + object.data['order_id'], object.data['class_id'], + object.data['family_id'], object.data['subfamily_id'], + object.data['genus_id'] + ].compact + end + + def common_names + CommonName.from('api_common_names_view common_names'). + where(taxon_concept_id: object.id). + select("language_name_en AS lang"). + select("string_agg(name, ', ') AS names"). + select(<<-SQL + CASE + WHEN UPPER(language_name_en) = 'ENGLISH' OR + UPPER(language_name_en) = 'FRENCH' OR + UPPER(language_name_en) = 'SPANISH' + THEN true + ELSE false + END AS convention_language + SQL + ). + group("language_name_en").order("language_name_en").all + end + + def distributions_with_tags_and_references + Distribution.from('api_distributions_view distributions'). + where(taxon_concept_id: object.id). + select("name_en AS name, name_en AS country, ARRAY_TO_STRING(tags, ',') AS tags_list, ARRAY_TO_STRING(citations, '; ') AS country_references"). + order('name_en').all + end + + def distributions + distributions_with_tags_and_references + end + + def subspecies + MTaxonConcept.where(:parent_id => object.id). + where("name_status NOT IN ('S', 'T', 'N')"). + select([:full_name, :author_year, :id, :show_in_species_plus]). + order(:full_name).all + end + + def standard_references + object.standard_taxon_concept_references + end + + def distribution_references + distributions_with_tags_and_references + end + + def cache_key + key = [ + self.class.name, + self.id, + object.updated_at, + object.dependents_updated_at, + object.m_taxon_concept.try(:updated_at) || "", + scope.current_user ? true : false + ] + Rails.logger.debug "CACHE KEY: #{key.inspect}" + key + end + + def nomenclature_notification + outputs = NomenclatureChange::Output.includes("nomenclature_change").where( + " + (taxon_concept_id = ? OR new_taxon_concept_id = ?) AND + nomenclature_changes.created_at > ? AND nomenclature_changes.status = 'submitted' + AND nomenclature_changes.created_at < ? + ", + object.id, object.id, 6.months.ago, Date.new(2017, 8, 1) + ) + + outputs.present? + end +end diff --git a/app/serializers/species/mobile/show_mobile_taxon_concept_serializer_cites.rb b/app/serializers/species/mobile/show_mobile_taxon_concept_serializer_cites.rb new file mode 100644 index 0000000000..c82a548de4 --- /dev/null +++ b/app/serializers/species/mobile/show_mobile_taxon_concept_serializer_cites.rb @@ -0,0 +1,21 @@ +class Species::Mobile::ShowMobileTaxonConceptSerializerCites < Species::Mobile::ShowMobileTaxonConceptSerializer + +attributes :id, :parent_id, :full_name, :author_year, + :common_names, :distributions, :subspecies, + :taxonomy, :kingdom_name, :phylum_name, :order_name, :class_name, :family_name, + :genus_name, :species_name, :rank_name, :name_status, :nomenclature_note_en, :nomenclature_notification + + + + def distributions_with_tags_and_references + Distribution.from('api_distributions_view distributions'). + where(taxon_concept_id: object.id). + select("name_en AS name, name_en AS country, ARRAY_TO_STRING(tags, ',') AS tags_list"). + order('name_en').all + end + + def distributions + distributions_with_tags_and_references + end + +end diff --git a/app/serializers/species/mobile/show_mobile_taxon_concept_serializer_cms.rb b/app/serializers/species/mobile/show_mobile_taxon_concept_serializer_cms.rb new file mode 100644 index 0000000000..960bb923c3 --- /dev/null +++ b/app/serializers/species/mobile/show_mobile_taxon_concept_serializer_cms.rb @@ -0,0 +1,70 @@ +class Species::Mobile::ShowMobileTaxonConceptSerializerCms < Species::Mobile::ShowMobileTaxonConceptSerializer + + attributes :cms_listing + has_many :cms_listing_changes, :serializer => Species::ListingChangeSerializer, + :key => :cms_listings + has_many :cms_instruments, :serializer => Species::CmsInstrumentsSerializer + + def cms_listing_changes + MCmsListingChange.from('cms_listing_changes_mview listing_changes_mview'). + where( + 'listing_changes_mview.taxon_concept_id' => object_and_children, + 'listing_changes_mview.show_in_history' => true + ). + where(<<-SQL + taxon_concepts_mview.rank_name = 'SPECIES' OR + ( + ( + taxon_concepts_mview.rank_name = 'SUBSPECIES' + OR taxon_concepts_mview.rank_name = 'VARIETY' + ) + AND listing_changes_mview.auto_note_en IS NULL + ) + SQL + ). + joins(<<-SQL + INNER JOIN taxon_concepts_mview + ON taxon_concepts_mview.id = listing_changes_mview.taxon_concept_id + SQL + ). + select(<<-SQL + CASE + WHEN listing_changes_mview.change_type_name = 'DELETION' + THEN 'f' + ELSE listing_changes_mview.is_current + END AS is_current, + listing_changes_mview.species_listing_name, + listing_changes_mview.party_id, + listing_changes_mview.party_full_name_en, + listing_changes_mview.effective_at, + listing_changes_mview.full_note_en, + listing_changes_mview.short_note_en, + listing_changes_mview.auto_note_en, + listing_changes_mview.inclusion_taxon_concept_id, + listing_changes_mview.inherited_full_note_en, + listing_changes_mview.inherited_short_note_en, + CASE + WHEN taxon_concepts_mview.rank_name = 'SUBSPECIES' + THEN '[SUBSPECIES listing ' || taxon_concepts_mview.full_name || ']' + WHEN taxon_concepts_mview.rank_name = 'VARIETY' + THEN '[VARIETY listing ' || taxon_concepts_mview.full_name || ']' + ELSE NULL + END AS subspecies_info + SQL + ). + order(<<-SQL + effective_at DESC, + subspecies_info DESC + SQL + ).all + end + + def cms_instruments + object.taxon_instruments.includes(:instrument) + end + + def cms_listing + object.listing && object.listing['cms_listing'] + end + +end From 8ab070739088bf9d877acf260da0f0e4587ed000 Mon Sep 17 00:00:00 2001 From: lucacug Date: Mon, 8 Aug 2022 15:55:36 +0100 Subject: [PATCH 02/15] feat: add author year to the auto complete tc view --- .../20220808123526.sql | 202 ++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 db/views/auto_complete_taxon_concepts_view/20220808123526.sql diff --git a/db/views/auto_complete_taxon_concepts_view/20220808123526.sql b/db/views/auto_complete_taxon_concepts_view/20220808123526.sql new file mode 100644 index 0000000000..65f1fee06f --- /dev/null +++ b/db/views/auto_complete_taxon_concepts_view/20220808123526.sql @@ -0,0 +1,202 @@ +WITH synonyms_segmented(taxon_concept_id, full_name, author_year, matched_taxon_concept_id, matched_name, matched_name_segment) AS ( + SELECT + atc.id, + atc.full_name, + atc.author_year, + tc.id, + tc.full_name, + UPPER(REGEXP_SPLIT_TO_TABLE(tc.full_name, ' ')) + FROM taxon_concepts tc + JOIN taxon_relationships tr + ON tr.other_taxon_concept_id = tc.id + JOIN taxon_relationship_types trt + ON trt.id = tr.taxon_relationship_type_id + AND trt.name = 'HAS_SYNONYM' + JOIN taxon_concepts atc + ON atc.id = tr.taxon_concept_id + WHERE tc.name_status = 'S' AND atc.name_status = 'A' +), scientific_names_segmented(taxon_concept_id, full_name, author_year, matched_taxon_concept_id, matched_name, matched_name_segment) AS ( + SELECT + id, + taxon_concepts.full_name, + taxon_concepts.author_year, + id, + taxon_concepts.full_name, + UPPER(REGEXP_SPLIT_TO_TABLE(full_name, ' ')) + FROM taxon_concepts +), unlisted_subspecies_segmented(taxon_concept_id, full_name, author_year, matched_taxon_concept_id, matched_name, matched_name_segment) AS ( + SELECT + parents.id, + parents.full_name, + parents.author_year, + taxon_concepts.id, + taxon_concepts.full_name, + UPPER(REGEXP_SPLIT_TO_TABLE(taxon_concepts.full_name, ' ')) + FROM taxon_concepts + JOIN ranks ON ranks.id = taxon_concepts.rank_id + AND ranks.name IN ('SUBSPECIES', 'VARIETY') + JOIN taxon_concepts parents + ON parents.id = taxon_concepts.parent_id + WHERE taxon_concepts.name_status NOT IN ('S', 'T', 'N') + AND parents.name_status = 'A' + + EXCEPT + + SELECT + parents.id, + parents.full_name, + parents.author_year, + taxon_concepts.id, + taxon_concepts.full_name, + UPPER(REGEXP_SPLIT_TO_TABLE(taxon_concepts.full_name, ' ')) + FROM taxon_concepts + JOIN ranks ON ranks.id = taxon_concepts.rank_id + AND ranks.name IN ('SUBSPECIES') -- VARIETY not here on purpose + JOIN taxon_concepts parents + ON parents.id = taxon_concepts.parent_id + JOIN taxonomies ON taxonomies.id = taxon_concepts.taxonomy_id + WHERE taxon_concepts.name_status NOT IN ('S', 'T', 'N') + AND parents.name_status = 'A' + AND CASE + WHEN taxonomies.name = 'CMS' + THEN (taxon_concepts.listing->'cms_historically_listed')::BOOLEAN + ELSE (taxon_concepts.listing->'cites_historically_listed')::BOOLEAN + OR (taxon_concepts.listing->'eu_historically_listed')::BOOLEAN + END +), taxon_common_names AS ( + SELECT + taxon_commons.*, + common_names.name + FROM taxon_commons + JOIN common_names + ON common_names.id = taxon_commons.common_name_id + JOIN languages + ON languages.id = common_names.language_id + AND languages.iso_code1 IN ('EN', 'ES', 'FR') +), common_names_segmented(taxon_concept_id, full_name, author_year, matched_taxon_concept_id, matched_name, matched_name_segment) AS ( + SELECT + taxon_concept_id, + taxon_concepts.full_name, + taxon_concepts.author_year, + NULL::INT, + taxon_common_names.name, + UPPER(REGEXP_SPLIT_TO_TABLE(taxon_common_names.name, E'\\s|''')) + FROM taxon_common_names + JOIN taxon_concepts + ON taxon_common_names.taxon_concept_id = taxon_concepts.id +), taxon_common_names_dehyphenated AS ( + SELECT + taxon_concept_id, + taxon_concepts.full_name, + taxon_concepts.author_year, + NULL::INT, + taxon_common_names.name, + UPPER(REPLACE(taxon_common_names.name, '-', ' ')) + FROM taxon_common_names + JOIN taxon_concepts + ON taxon_common_names.taxon_concept_id = taxon_concepts.id + WHERE STRPOS(taxon_common_names.name, '-') > 0 +), common_names_segmented_dehyphenated AS ( + SELECT taxon_concept_id, full_name, author_year, matched_taxon_concept_id, matched_name, matched_name_segment + FROM common_names_segmented + UNION + SELECT taxon_concept_id, full_name, author_year, matched_taxon_concept_id, matched_name, REGEXP_SPLIT_TO_TABLE(matched_name_segment, E'-') + FROM common_names_segmented + WHERE STRPOS(matched_name_segment, '-') > 0 + UNION + SELECT * FROM taxon_common_names_dehyphenated +), all_names_segmented_cleaned AS ( + SELECT * FROM ( + SELECT taxon_concept_id, full_name, author_year, matched_taxon_concept_id, matched_name, + CASE + WHEN POSITION(matched_name_segment IN + UPPER(matched_name) + ) = 1 THEN UPPER(matched_name) + ELSE matched_name_segment + END, type_of_match + FROM ( + SELECT *, 'SELF' AS type_of_match + FROM scientific_names_segmented + UNION + SELECT *, 'SYNONYM' + FROM synonyms_segmented + UNION + SELECT *, 'SUBSPECIES' + FROM unlisted_subspecies_segmented + UNION + SELECT *, 'COMMON_NAME' + FROM common_names_segmented_dehyphenated + ) all_names_segmented + ) all_names_segmented_no_prefixes + WHERE LENGTH(matched_name_segment) >= 3 +), taxa_with_visibility_flags AS ( + SELECT taxon_concepts.id, + CASE + WHEN taxonomies.name = 'CITES_EU' THEN TRUE + ELSE FALSE + END AS taxonomy_is_cites_eu, + name_status, + ranks.name AS rank_name, + ranks.display_name_en AS rank_display_name_en, + ranks.display_name_es AS rank_display_name_es, + ranks.display_name_fr AS rank_display_name_fr, + ranks.taxonomic_position AS rank_order, + taxon_concepts.taxonomic_position, + CASE + WHEN + name_status = 'A' + AND ( + ranks.name != 'SUBSPECIES' + AND ranks.name != 'VARIETY' + OR taxonomies.name = 'CITES_EU' + AND ( + (listing->'cites_historically_listed')::BOOLEAN + OR (listing->'eu_historically_listed')::BOOLEAN + ) + OR taxonomies.name = 'CMS' + AND (listing->'cms_historically_listed')::BOOLEAN + ) + THEN TRUE + ELSE FALSE + END AS show_in_species_plus_ac, + CASE + WHEN + name_status = 'A' + AND ( + ranks.name != 'SUBSPECIES' + AND ranks.name != 'VARIETY' + OR (listing->'cites_show')::BOOLEAN + ) + THEN TRUE + ELSE FALSE + END AS show_in_checklist_ac, + CASE + WHEN + taxonomies.name = 'CITES_EU' + AND ARRAY['A', 'H', 'N']::VARCHAR[] && ARRAY[name_status] + THEN TRUE + ELSE FALSE + END AS show_in_trade_ac, + CASE + WHEN + taxonomies.name = 'CITES_EU' + AND ARRAY['A', 'H', 'N', 'T']::VARCHAR[] && ARRAY[name_status] + THEN TRUE + ELSE FALSE + END AS show_in_trade_internal_ac + FROM taxon_concepts + JOIN ranks ON ranks.id = rank_id + JOIN taxonomies ON taxonomies.id = taxon_concepts.taxonomy_id +) +SELECT + t1.*, + matched_name_segment AS name_for_matching, + matched_taxon_concept_id AS matched_id, + matched_name, + full_name, + author_year, + type_of_match +FROM taxa_with_visibility_flags t1 +JOIN all_names_segmented_cleaned t2 +ON t1.id = t2.taxon_concept_id +WHERE LENGTH(matched_name_segment) >= 3; From 530f9a6c6a5ee4cd6d361504e372cfb89a9e57c3 Mon Sep 17 00:00:00 2001 From: lucacug Date: Mon, 8 Aug 2022 15:57:27 +0100 Subject: [PATCH 03/15] feat: add a new psql function to rebuild auto complete tc mview, which is not really a mview but a table built on top of a sql view --- ...ild_auto_complete_taxon_concepts_mview.sql | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 db/mviews/011_rebuild_auto_complete_taxon_concepts_mview.sql diff --git a/db/mviews/011_rebuild_auto_complete_taxon_concepts_mview.sql b/db/mviews/011_rebuild_auto_complete_taxon_concepts_mview.sql new file mode 100644 index 0000000000..6a668c7458 --- /dev/null +++ b/db/mviews/011_rebuild_auto_complete_taxon_concepts_mview.sql @@ -0,0 +1,33 @@ +CREATE OR REPLACE FUNCTION rebuild_auto_complete_taxon_concepts_mview() RETURNS void + LANGUAGE plpgsql + AS $$ + BEGIN + + DROP table IF EXISTS auto_complete_taxon_concepts_mview_tmp CASCADE; + RAISE INFO 'Creating auto complete taxon concepts materialized view (tmp)'; + CREATE TABLE auto_complete_taxon_concepts_mview_tmp AS + SELECT * FROM auto_complete_taxon_concepts_view; + + RAISE INFO 'Creating indexes on auto complete taxon concepts materialized view (tmp)'; + + --this one used for Species+ autocomplete (both main and higher taxa in downloads) + CREATE INDEX ON auto_complete_taxon_concepts_mview_tmp + USING BTREE(name_for_matching text_pattern_ops, taxonomy_is_cites_eu, type_of_match, show_in_species_plus_ac); + --this one used for Checklist autocomplete + CREATE INDEX ON auto_complete_taxon_concepts_mview_tmp + USING BTREE(name_for_matching text_pattern_ops, taxonomy_is_cites_eu, type_of_match, show_in_checklist_ac); + --this one used for Trade autocomplete + CREATE INDEX ON auto_complete_taxon_concepts_mview_tmp + USING BTREE(name_for_matching text_pattern_ops, taxonomy_is_cites_eu, type_of_match, show_in_trade_ac); + --this one used for Trade internal autocomplete + CREATE INDEX ON auto_complete_taxon_concepts_mview_tmp + USING BTREE(name_for_matching text_pattern_ops, taxonomy_is_cites_eu, type_of_match, show_in_trade_internal_ac); + + RAISE INFO 'Swapping auto complete taxon concepts materialized view'; + DROP table IF EXISTS auto_complete_taxon_concepts_mview CASCADE; + ALTER TABLE auto_complete_taxon_concepts_mview_tmp RENAME TO auto_complete_taxon_concepts_mview; + + END; + $$; + +COMMENT ON FUNCTION rebuild_taxon_concepts_mview() IS 'Procedure to rebuild taxon concepts materialized view in the database.'; From fccd49010535794336899823d45c87aac095bbb4 Mon Sep 17 00:00:00 2001 From: lucacug Date: Mon, 8 Aug 2022 15:58:58 +0100 Subject: [PATCH 04/15] feat: add migration to rebuild autocomplete tc view and mview, the latter done by reading the sql file where the function definition lives --- ...08124523_add_author_year_to_autocomplete_view.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 db/migrate/20220808124523_add_author_year_to_autocomplete_view.rb diff --git a/db/migrate/20220808124523_add_author_year_to_autocomplete_view.rb b/db/migrate/20220808124523_add_author_year_to_autocomplete_view.rb new file mode 100644 index 0000000000..ceeae18f12 --- /dev/null +++ b/db/migrate/20220808124523_add_author_year_to_autocomplete_view.rb @@ -0,0 +1,13 @@ +class AddAuthorYearToAutocompleteView < ActiveRecord::Migration + def up + execute "DROP VIEW IF EXISTS auto_complete_taxon_concepts_view" + execute "CREATE VIEW auto_complete_taxon_concepts_view AS #{view_sql('20220808123526', 'auto_complete_taxon_concepts_view')}" + execute File.read(File.expand_path('../../mviews/011_rebuild_auto_complete_taxon_concepts_mview.sql', __FILE__)) + end + + def down + execute "DROP VIEW IF EXISTS auto_complete_taxon_concepts_view" + execute "CREATE VIEW auto_complete_taxon_concepts_view AS #{view_sql('20150318150923', 'auto_complete_taxon_concepts_view')}" + execute File.read(File.expand_path('../mviews/011_rebuild_auto_complete_taxon_concepts_mview.sql', __FILE__)) + end +end From ec085a0ee8720a9d3b8fff1cfcabe89e2d6cb695 Mon Sep 17 00:00:00 2001 From: lucacug Date: Mon, 8 Aug 2022 16:01:58 +0100 Subject: [PATCH 05/15] feat: add author year attribute to autocomplete api response --- app/models/species/taxon_concept_prefix_matcher.rb | 4 ++-- .../species/autocomplete_taxon_concept_serializer.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/species/taxon_concept_prefix_matcher.rb b/app/models/species/taxon_concept_prefix_matcher.rb index cb5069a9f9..f0d7a5874f 100644 --- a/app/models/species/taxon_concept_prefix_matcher.rb +++ b/app/models/species/taxon_concept_prefix_matcher.rb @@ -73,7 +73,7 @@ def initialize_query end @query = @query. - select('id, full_name, rank_name, name_status, + select('id, full_name, rank_name, name_status, author_year, ARRAY_AGG_NOTNULL( DISTINCT CASE WHEN matched_name != full_name THEN matched_name ELSE NULL @@ -85,7 +85,7 @@ def initialize_query rank_display_name_en, rank_display_name_es, rank_display_name_fr'). where(type_of_match: types_of_match). group([ - :id, :full_name, :rank_name, :name_status, :rank_order, + :id, :full_name, :rank_name, :name_status, :author_year, :rank_order, :rank_display_name_en, :rank_display_name_es, :rank_display_name_fr ]) diff --git a/app/serializers/species/autocomplete_taxon_concept_serializer.rb b/app/serializers/species/autocomplete_taxon_concept_serializer.rb index e50aec72d0..6dcf168041 100644 --- a/app/serializers/species/autocomplete_taxon_concept_serializer.rb +++ b/app/serializers/species/autocomplete_taxon_concept_serializer.rb @@ -1,5 +1,5 @@ class Species::AutocompleteTaxonConceptSerializer < ActiveModel::Serializer - attributes :id, :full_name, :rank_name, :name_status, :matching_names + attributes :id, :full_name, :author_year, :rank_name, :name_status, :matching_names def rank_name rank_with_locale = "rank_display_name_#{I18n.locale.to_s}" From cc86f79b9ca70d76d72cc181af763aab245b27b7 Mon Sep 17 00:00:00 2001 From: roshan-mathewtech Date: Tue, 9 Aug 2022 18:47:13 +0100 Subject: [PATCH 06/15] Modify rebuild mview --- .../20220808124523_add_author_year_to_autocomplete_view.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/db/migrate/20220808124523_add_author_year_to_autocomplete_view.rb b/db/migrate/20220808124523_add_author_year_to_autocomplete_view.rb index ceeae18f12..59f86dd411 100644 --- a/db/migrate/20220808124523_add_author_year_to_autocomplete_view.rb +++ b/db/migrate/20220808124523_add_author_year_to_autocomplete_view.rb @@ -3,11 +3,13 @@ def up execute "DROP VIEW IF EXISTS auto_complete_taxon_concepts_view" execute "CREATE VIEW auto_complete_taxon_concepts_view AS #{view_sql('20220808123526', 'auto_complete_taxon_concepts_view')}" execute File.read(File.expand_path('../../mviews/011_rebuild_auto_complete_taxon_concepts_mview.sql', __FILE__)) + execute "SELECT * FROM rebuild_auto_complete_taxon_concepts_mview()" end def down execute "DROP VIEW IF EXISTS auto_complete_taxon_concepts_view" execute "CREATE VIEW auto_complete_taxon_concepts_view AS #{view_sql('20150318150923', 'auto_complete_taxon_concepts_view')}" - execute File.read(File.expand_path('../mviews/011_rebuild_auto_complete_taxon_concepts_mview.sql', __FILE__)) + execute File.read(File.expand_path('../../mviews/011_rebuild_auto_complete_taxon_concepts_mview.sql', __FILE__)) + execute "SELECT * FROM rebuild_auto_complete_taxon_concepts_mview()" end end From 2f35233eb51dd8ed905250147b85d11d510772bf Mon Sep 17 00:00:00 2001 From: roshan-mathewtech Date: Wed, 10 Aug 2022 12:17:04 +0100 Subject: [PATCH 07/15] Modify serializer api for mobile endpoint - removed separate mobile namespace --- .../api/v1/taxon_concepts_controller.rb | 6 +- .../show_mobile_taxon_concept_serializer.rb | 135 ------------------ ...w_mobile_taxon_concept_serializer_cites.rb | 21 --- ...how_mobile_taxon_concept_serializer_cms.rb | 70 --------- .../species/show_taxon_concept_serializer.rb | 11 +- .../show_taxon_concept_serializer_cites.rb | 24 ++++ .../show_taxon_concept_serializer_cms.rb | 8 ++ 7 files changed, 44 insertions(+), 231 deletions(-) delete mode 100644 app/serializers/species/mobile/show_mobile_taxon_concept_serializer.rb delete mode 100644 app/serializers/species/mobile/show_mobile_taxon_concept_serializer_cites.rb delete mode 100644 app/serializers/species/mobile/show_mobile_taxon_concept_serializer_cms.rb diff --git a/app/controllers/api/v1/taxon_concepts_controller.rb b/app/controllers/api/v1/taxon_concepts_controller.rb index 0c8dfb425a..db44f11dff 100644 --- a/app/controllers/api/v1/taxon_concepts_controller.rb +++ b/app/controllers/api/v1/taxon_concepts_controller.rb @@ -26,12 +26,12 @@ def show :cites_suspensions => :geo_entity). includes(:taxonomy).find(params[:id]) if @taxon_concept.taxonomy.name == Taxonomy::CMS - s = params[:mobile].present? ? Species::Mobile::ShowMobileTaxonConceptSerializerCms : Species::ShowTaxonConceptSerializerCms + s = Species::ShowTaxonConceptSerializerCms else - s = params[:mobile].present? ? Species::Mobile::ShowMobileTaxonConceptSerializerCites : Species::ShowTaxonConceptSerializerCites + s = Species::ShowTaxonConceptSerializerCites end render :json => @taxon_concept, - :serializer => s + :serializer => s, :mobile => params[:mobile] end protected diff --git a/app/serializers/species/mobile/show_mobile_taxon_concept_serializer.rb b/app/serializers/species/mobile/show_mobile_taxon_concept_serializer.rb deleted file mode 100644 index cab15577d6..0000000000 --- a/app/serializers/species/mobile/show_mobile_taxon_concept_serializer.rb +++ /dev/null @@ -1,135 +0,0 @@ -class Species::Mobile::ShowMobileTaxonConceptSerializer < ActiveModel::Serializer - cached - root 'taxon_concept' - attributes :id, :parent_id, :full_name, :author_year, - :common_names, :distributions, :subspecies, - :taxonomy, :kingdom_name, :phylum_name, :order_name, :class_name, :family_name, - :genus_name, :species_name, :rank_name, :name_status, :nomenclature_note_en, :nomenclature_notification - - has_many :synonyms, :serializer => Species::SynonymSerializer - - - def rank_name - object.data['rank_name'] - end - - def kingdom_name - object.data['kingdom_name'] - end - - def phylum_name - object.data['phylum_name'] - end - - def class_name - object.data['class_name'] - end - - def order_name - object.data['order_name'] - end - - def family_name - object.data['family_name'] - end - - def genus_name - object.data['genus_name'] - end - - def species_name - object.data['species_name'] - end - - def taxonomy - object.taxonomy.name.downcase - end - - def synonyms - object.synonyms. - order("full_name") - end - - def object_and_children - [object.id] + object.children.pluck(:id) - end - - def ancestors - [ - object.data['kingdom_id'], object.data['phylum_id'], - object.data['order_id'], object.data['class_id'], - object.data['family_id'], object.data['subfamily_id'], - object.data['genus_id'] - ].compact - end - - def common_names - CommonName.from('api_common_names_view common_names'). - where(taxon_concept_id: object.id). - select("language_name_en AS lang"). - select("string_agg(name, ', ') AS names"). - select(<<-SQL - CASE - WHEN UPPER(language_name_en) = 'ENGLISH' OR - UPPER(language_name_en) = 'FRENCH' OR - UPPER(language_name_en) = 'SPANISH' - THEN true - ELSE false - END AS convention_language - SQL - ). - group("language_name_en").order("language_name_en").all - end - - def distributions_with_tags_and_references - Distribution.from('api_distributions_view distributions'). - where(taxon_concept_id: object.id). - select("name_en AS name, name_en AS country, ARRAY_TO_STRING(tags, ',') AS tags_list, ARRAY_TO_STRING(citations, '; ') AS country_references"). - order('name_en').all - end - - def distributions - distributions_with_tags_and_references - end - - def subspecies - MTaxonConcept.where(:parent_id => object.id). - where("name_status NOT IN ('S', 'T', 'N')"). - select([:full_name, :author_year, :id, :show_in_species_plus]). - order(:full_name).all - end - - def standard_references - object.standard_taxon_concept_references - end - - def distribution_references - distributions_with_tags_and_references - end - - def cache_key - key = [ - self.class.name, - self.id, - object.updated_at, - object.dependents_updated_at, - object.m_taxon_concept.try(:updated_at) || "", - scope.current_user ? true : false - ] - Rails.logger.debug "CACHE KEY: #{key.inspect}" - key - end - - def nomenclature_notification - outputs = NomenclatureChange::Output.includes("nomenclature_change").where( - " - (taxon_concept_id = ? OR new_taxon_concept_id = ?) AND - nomenclature_changes.created_at > ? AND nomenclature_changes.status = 'submitted' - AND nomenclature_changes.created_at < ? - ", - object.id, object.id, 6.months.ago, Date.new(2017, 8, 1) - ) - - outputs.present? - end -end diff --git a/app/serializers/species/mobile/show_mobile_taxon_concept_serializer_cites.rb b/app/serializers/species/mobile/show_mobile_taxon_concept_serializer_cites.rb deleted file mode 100644 index c82a548de4..0000000000 --- a/app/serializers/species/mobile/show_mobile_taxon_concept_serializer_cites.rb +++ /dev/null @@ -1,21 +0,0 @@ -class Species::Mobile::ShowMobileTaxonConceptSerializerCites < Species::Mobile::ShowMobileTaxonConceptSerializer - -attributes :id, :parent_id, :full_name, :author_year, - :common_names, :distributions, :subspecies, - :taxonomy, :kingdom_name, :phylum_name, :order_name, :class_name, :family_name, - :genus_name, :species_name, :rank_name, :name_status, :nomenclature_note_en, :nomenclature_notification - - - - def distributions_with_tags_and_references - Distribution.from('api_distributions_view distributions'). - where(taxon_concept_id: object.id). - select("name_en AS name, name_en AS country, ARRAY_TO_STRING(tags, ',') AS tags_list"). - order('name_en').all - end - - def distributions - distributions_with_tags_and_references - end - -end diff --git a/app/serializers/species/mobile/show_mobile_taxon_concept_serializer_cms.rb b/app/serializers/species/mobile/show_mobile_taxon_concept_serializer_cms.rb deleted file mode 100644 index 960bb923c3..0000000000 --- a/app/serializers/species/mobile/show_mobile_taxon_concept_serializer_cms.rb +++ /dev/null @@ -1,70 +0,0 @@ -class Species::Mobile::ShowMobileTaxonConceptSerializerCms < Species::Mobile::ShowMobileTaxonConceptSerializer - - attributes :cms_listing - has_many :cms_listing_changes, :serializer => Species::ListingChangeSerializer, - :key => :cms_listings - has_many :cms_instruments, :serializer => Species::CmsInstrumentsSerializer - - def cms_listing_changes - MCmsListingChange.from('cms_listing_changes_mview listing_changes_mview'). - where( - 'listing_changes_mview.taxon_concept_id' => object_and_children, - 'listing_changes_mview.show_in_history' => true - ). - where(<<-SQL - taxon_concepts_mview.rank_name = 'SPECIES' OR - ( - ( - taxon_concepts_mview.rank_name = 'SUBSPECIES' - OR taxon_concepts_mview.rank_name = 'VARIETY' - ) - AND listing_changes_mview.auto_note_en IS NULL - ) - SQL - ). - joins(<<-SQL - INNER JOIN taxon_concepts_mview - ON taxon_concepts_mview.id = listing_changes_mview.taxon_concept_id - SQL - ). - select(<<-SQL - CASE - WHEN listing_changes_mview.change_type_name = 'DELETION' - THEN 'f' - ELSE listing_changes_mview.is_current - END AS is_current, - listing_changes_mview.species_listing_name, - listing_changes_mview.party_id, - listing_changes_mview.party_full_name_en, - listing_changes_mview.effective_at, - listing_changes_mview.full_note_en, - listing_changes_mview.short_note_en, - listing_changes_mview.auto_note_en, - listing_changes_mview.inclusion_taxon_concept_id, - listing_changes_mview.inherited_full_note_en, - listing_changes_mview.inherited_short_note_en, - CASE - WHEN taxon_concepts_mview.rank_name = 'SUBSPECIES' - THEN '[SUBSPECIES listing ' || taxon_concepts_mview.full_name || ']' - WHEN taxon_concepts_mview.rank_name = 'VARIETY' - THEN '[VARIETY listing ' || taxon_concepts_mview.full_name || ']' - ELSE NULL - END AS subspecies_info - SQL - ). - order(<<-SQL - effective_at DESC, - subspecies_info DESC - SQL - ).all - end - - def cms_instruments - object.taxon_instruments.includes(:instrument) - end - - def cms_listing - object.listing && object.listing['cms_listing'] - end - -end diff --git a/app/serializers/species/show_taxon_concept_serializer.rb b/app/serializers/species/show_taxon_concept_serializer.rb index a14ac8cfc2..bfa3790ba5 100644 --- a/app/serializers/species/show_taxon_concept_serializer.rb +++ b/app/serializers/species/show_taxon_concept_serializer.rb @@ -90,7 +90,14 @@ def distributions_with_tags_and_references end def distributions - distributions_with_tags_and_references + @options[:mobile].present? && taxonomy == 'cites_eu' ? distributions_with_tags_and_references_mobile : distributions_with_tags_and_references + end + + def distributions_with_tags_and_references_mobile + Distribution.from('api_distributions_view distributions'). + where(taxon_concept_id: object.id). + select("name_en AS name, name_en AS country, ARRAY_TO_STRING(tags, ',') AS tags_list"). + order('name_en').all end def subspecies @@ -105,7 +112,7 @@ def standard_references end def distribution_references - distributions_with_tags_and_references + @options[:mobile].present? ? distributions_with_tags_and_references_mobile : distributions_with_tags_and_references end def cache_key diff --git a/app/serializers/species/show_taxon_concept_serializer_cites.rb b/app/serializers/species/show_taxon_concept_serializer_cites.rb index 06de6edf39..6d74155c88 100644 --- a/app/serializers/species/show_taxon_concept_serializer_cites.rb +++ b/app/serializers/species/show_taxon_concept_serializer_cites.rb @@ -9,6 +9,30 @@ class Species::ShowTaxonConceptSerializerCites < Species::ShowTaxonConceptSerial :key => :eu_listings has_many :eu_decisions, :serializer => Species::EuDecisionSerializer + def include_distribution_references? + !@options[:mobile].present? + end + + def include_standard_references? + !@options[:mobile].present? + end + + def include_eu_listing_changes? + !@options[:mobile].present? + end + + def include_taxon_concept_references? + !@options[:mobile].present? + end + + def include_cites_listing_changes? + !@options[:mobile].present? + end + + def include_subspecies? + !@options[:mobile].present? + end + def quotas Quota.from('api_cites_quotas_view trade_restrictions'). where(" diff --git a/app/serializers/species/show_taxon_concept_serializer_cms.rb b/app/serializers/species/show_taxon_concept_serializer_cms.rb index 2576922f15..f41d03d3dc 100644 --- a/app/serializers/species/show_taxon_concept_serializer_cms.rb +++ b/app/serializers/species/show_taxon_concept_serializer_cms.rb @@ -5,6 +5,14 @@ class Species::ShowTaxonConceptSerializerCms < Species::ShowTaxonConceptSerializ :key => :cms_listings has_many :cms_instruments, :serializer => Species::CmsInstrumentsSerializer + def include_standard_references? + !@options[:mobile].present? + end + + def include_taxon_concept_references? + !@options[:mobile].present? + end + def cms_listing_changes MCmsListingChange.from('cms_listing_changes_mview listing_changes_mview'). where( From cdd4385c4ddf6c2fab66b543bda33396229954f0 Mon Sep 17 00:00:00 2001 From: lucacug Date: Fri, 12 Aug 2022 09:46:37 +0100 Subject: [PATCH 08/15] feat: add iso2 attribute to distribution object in the serializer --- app/serializers/species/show_taxon_concept_serializer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/serializers/species/show_taxon_concept_serializer.rb b/app/serializers/species/show_taxon_concept_serializer.rb index bfa3790ba5..ab9d367747 100644 --- a/app/serializers/species/show_taxon_concept_serializer.rb +++ b/app/serializers/species/show_taxon_concept_serializer.rb @@ -96,7 +96,7 @@ def distributions def distributions_with_tags_and_references_mobile Distribution.from('api_distributions_view distributions'). where(taxon_concept_id: object.id). - select("name_en AS name, name_en AS country, ARRAY_TO_STRING(tags, ',') AS tags_list"). + select("name_en AS name, name_en AS country, iso_code2, ARRAY_TO_STRING(tags, ',') AS tags_list"). order('name_en').all end From 64599aab7d0cfc916c98726944232d05e9e3e16d Mon Sep 17 00:00:00 2001 From: roshan-mathewtech Date: Fri, 12 Aug 2022 12:09:01 +0100 Subject: [PATCH 09/15] code review changes, removed few fields from the mobile response --- .../species/cites_suspension_serializer.rb | 12 ++++++++++++ app/serializers/species/eu_decision_serializer.rb | 8 ++++++++ app/serializers/species/quota_serializer.rb | 8 ++++++++ .../species/show_taxon_concept_serializer.rb | 6 +++--- .../species/show_taxon_concept_serializer_cites.rb | 14 +++++--------- .../species/show_taxon_concept_serializer_cms.rb | 12 ++++++++++-- 6 files changed, 46 insertions(+), 14 deletions(-) diff --git a/app/serializers/species/cites_suspension_serializer.rb b/app/serializers/species/cites_suspension_serializer.rb index d1072a1668..b1937c5e42 100644 --- a/app/serializers/species/cites_suspension_serializer.rb +++ b/app/serializers/species/cites_suspension_serializer.rb @@ -13,4 +13,16 @@ def geo_entity def start_notification object['start_notification'] end + + def include_nomenclature_note_fr? + @options[:mobile].blank? + end + + def include_nomenclature_note_es? + @options[:mobile].blank? + end + + def include_applies_to_import? + @options[:mobile].blank? + end end diff --git a/app/serializers/species/eu_decision_serializer.rb b/app/serializers/species/eu_decision_serializer.rb index 0725e75082..0dacab2fa7 100644 --- a/app/serializers/species/eu_decision_serializer.rb +++ b/app/serializers/species/eu_decision_serializer.rb @@ -38,4 +38,12 @@ def term def private_url scope.current_user ? object['private_url'] : nil end + + def include_nomenclature_note_fr? + @options[:mobile].blank? + end + + def include_nomenclature_note_es? + @options[:mobile].blank? + end end diff --git a/app/serializers/species/quota_serializer.rb b/app/serializers/species/quota_serializer.rb index 14f719a016..dc90580827 100644 --- a/app/serializers/species/quota_serializer.rb +++ b/app/serializers/species/quota_serializer.rb @@ -16,4 +16,12 @@ def unit def quota object['quota_for_display'] end + + def include_nomenclature_note_fr? + @options[:mobile].blank? + end + + def include_nomenclature_note_es? + @options[:mobile].blank? + end end diff --git a/app/serializers/species/show_taxon_concept_serializer.rb b/app/serializers/species/show_taxon_concept_serializer.rb index bfa3790ba5..4100bebfec 100644 --- a/app/serializers/species/show_taxon_concept_serializer.rb +++ b/app/serializers/species/show_taxon_concept_serializer.rb @@ -90,13 +90,13 @@ def distributions_with_tags_and_references end def distributions - @options[:mobile].present? && taxonomy == 'cites_eu' ? distributions_with_tags_and_references_mobile : distributions_with_tags_and_references + @options[:mobile].blank? ? distributions_with_tags_and_references : distributions_with_tags_and_references_mobile end def distributions_with_tags_and_references_mobile Distribution.from('api_distributions_view distributions'). where(taxon_concept_id: object.id). - select("name_en AS name, name_en AS country, ARRAY_TO_STRING(tags, ',') AS tags_list"). + select("name_en AS country, ARRAY_TO_STRING(tags, ',') AS tags_list"). order('name_en').all end @@ -112,7 +112,7 @@ def standard_references end def distribution_references - @options[:mobile].present? ? distributions_with_tags_and_references_mobile : distributions_with_tags_and_references + @options[:mobile].blank? ? distributions_with_tags_and_references : distributions_with_tags_and_references_mobile end def cache_key diff --git a/app/serializers/species/show_taxon_concept_serializer_cites.rb b/app/serializers/species/show_taxon_concept_serializer_cites.rb index 6d74155c88..a17b5bf3bf 100644 --- a/app/serializers/species/show_taxon_concept_serializer_cites.rb +++ b/app/serializers/species/show_taxon_concept_serializer_cites.rb @@ -10,27 +10,23 @@ class Species::ShowTaxonConceptSerializerCites < Species::ShowTaxonConceptSerial has_many :eu_decisions, :serializer => Species::EuDecisionSerializer def include_distribution_references? - !@options[:mobile].present? + @options[:mobile].blank? end def include_standard_references? - !@options[:mobile].present? + @options[:mobile].blank? end def include_eu_listing_changes? - !@options[:mobile].present? + @options[:mobile].blank? end def include_taxon_concept_references? - !@options[:mobile].present? + @options[:mobile].blank? end def include_cites_listing_changes? - !@options[:mobile].present? - end - - def include_subspecies? - !@options[:mobile].present? + @options[:mobile].blank? end def quotas diff --git a/app/serializers/species/show_taxon_concept_serializer_cms.rb b/app/serializers/species/show_taxon_concept_serializer_cms.rb index f41d03d3dc..5d267d43df 100644 --- a/app/serializers/species/show_taxon_concept_serializer_cms.rb +++ b/app/serializers/species/show_taxon_concept_serializer_cms.rb @@ -6,11 +6,19 @@ class Species::ShowTaxonConceptSerializerCms < Species::ShowTaxonConceptSerializ has_many :cms_instruments, :serializer => Species::CmsInstrumentsSerializer def include_standard_references? - !@options[:mobile].present? + @options[:mobile].blank? end def include_taxon_concept_references? - !@options[:mobile].present? + @options[:mobile].blank? + end + + def include_distribution_references? + @options[:mobile].blank? + end + + def include_cms_instruments? + @options[:mobile].blank? end def cms_listing_changes From bf2831fcbab67dd47ba129067545bf4fd2f38c78 Mon Sep 17 00:00:00 2001 From: lucacug Date: Fri, 12 Aug 2022 17:22:26 +0100 Subject: [PATCH 10/15] refactor: rename mobile param to trimmed, add trimmed param in the cache key to avoid conflicts and remove further attributes from the trimmed version --- .../api/v1/taxon_concepts_controller.rb | 2 +- .../species/cites_suspension_serializer.rb | 6 +++--- .../species/eu_decision_serializer.rb | 4 ++-- .../species/listing_change_serializer.rb | 10 ++++++++++ app/serializers/species/quota_serializer.rb | 4 ++-- .../species/show_taxon_concept_serializer.rb | 19 ++++++++++++++----- .../show_taxon_concept_serializer_cites.rb | 14 +++----------- .../show_taxon_concept_serializer_cms.rb | 10 +++++----- 8 files changed, 40 insertions(+), 29 deletions(-) diff --git a/app/controllers/api/v1/taxon_concepts_controller.rb b/app/controllers/api/v1/taxon_concepts_controller.rb index db44f11dff..9c402613b5 100644 --- a/app/controllers/api/v1/taxon_concepts_controller.rb +++ b/app/controllers/api/v1/taxon_concepts_controller.rb @@ -31,7 +31,7 @@ def show s = Species::ShowTaxonConceptSerializerCites end render :json => @taxon_concept, - :serializer => s, :mobile => params[:mobile] + :serializer => s, :trimmed => params[:trimmed] end protected diff --git a/app/serializers/species/cites_suspension_serializer.rb b/app/serializers/species/cites_suspension_serializer.rb index b1937c5e42..e03c28d517 100644 --- a/app/serializers/species/cites_suspension_serializer.rb +++ b/app/serializers/species/cites_suspension_serializer.rb @@ -15,14 +15,14 @@ def start_notification end def include_nomenclature_note_fr? - @options[:mobile].blank? + @options[:trimmed].blank? end def include_nomenclature_note_es? - @options[:mobile].blank? + @options[:trimmed].blank? end def include_applies_to_import? - @options[:mobile].blank? + @options[:trimmed].blank? end end diff --git a/app/serializers/species/eu_decision_serializer.rb b/app/serializers/species/eu_decision_serializer.rb index 0dacab2fa7..6ea692f200 100644 --- a/app/serializers/species/eu_decision_serializer.rb +++ b/app/serializers/species/eu_decision_serializer.rb @@ -40,10 +40,10 @@ def private_url end def include_nomenclature_note_fr? - @options[:mobile].blank? + @options[:trimmed].blank? end def include_nomenclature_note_es? - @options[:mobile].blank? + @options[:trimmed].blank? end end diff --git a/app/serializers/species/listing_change_serializer.rb b/app/serializers/species/listing_change_serializer.rb index ce273ca2ff..3bd50874d5 100644 --- a/app/serializers/species/listing_change_serializer.rb +++ b/app/serializers/species/listing_change_serializer.rb @@ -3,6 +3,16 @@ class Species::ListingChangeSerializer < ActiveModel::Serializer :effective_at_formatted, :short_note_en, :full_note_en, :auto_note, :is_inclusion, :subspecies_info, :inherited_full_note_en, :inherited_short_note_en + def include_is_inclusion? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + + def include_subspecies_info? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + def is_inclusion object.inclusion_taxon_concept_id end diff --git a/app/serializers/species/quota_serializer.rb b/app/serializers/species/quota_serializer.rb index dc90580827..d0d084fd7f 100644 --- a/app/serializers/species/quota_serializer.rb +++ b/app/serializers/species/quota_serializer.rb @@ -18,10 +18,10 @@ def quota end def include_nomenclature_note_fr? - @options[:mobile].blank? + @options[:trimmed].blank? end def include_nomenclature_note_es? - @options[:mobile].blank? + @options[:trimmed].blank? end end diff --git a/app/serializers/species/show_taxon_concept_serializer.rb b/app/serializers/species/show_taxon_concept_serializer.rb index 9069a9a475..0df0742c03 100644 --- a/app/serializers/species/show_taxon_concept_serializer.rb +++ b/app/serializers/species/show_taxon_concept_serializer.rb @@ -10,6 +10,14 @@ class Species::ShowTaxonConceptSerializer < ActiveModel::Serializer has_many :taxon_concept_references, :serializer => Species::ReferenceSerializer, :key => :references + def include_parent_id? + @options[:trimmed].blank? + end + + def include_nomenclature_notification? + @options[:trimmed].blank? + end + def rank_name object.data['rank_name'] end @@ -90,13 +98,13 @@ def distributions_with_tags_and_references end def distributions - @options[:mobile].blank? ? distributions_with_tags_and_references : distributions_with_tags_and_references_mobile + @options[:trimmed].blank? ? distributions_with_tags_and_references : distributions_with_tags_and_references_trimmed end - def distributions_with_tags_and_references_mobile + def distributions_with_tags_and_references_trimmed Distribution.from('api_distributions_view distributions'). where(taxon_concept_id: object.id). - select("name_en AS name, name_en AS country, iso_code2, ARRAY_TO_STRING(tags, ',') AS tags_list"). + select("name_en AS country, iso_code2, ARRAY_TO_STRING(tags, ',') AS tags_list"). order('name_en').all end @@ -112,7 +120,7 @@ def standard_references end def distribution_references - @options[:mobile].blank? ? distributions_with_tags_and_references : distributions_with_tags_and_references_mobile + @options[:trimmed].blank? ? distributions_with_tags_and_references : distributions_with_tags_and_references_trimmed end def cache_key @@ -122,7 +130,8 @@ def cache_key object.updated_at, object.dependents_updated_at, object.m_taxon_concept.try(:updated_at) || "", - scope.current_user ? true : false + scope.current_user ? true : false, + @options[:trimmed] == 'true' ? true : false ] Rails.logger.debug "CACHE KEY: #{key.inspect}" key diff --git a/app/serializers/species/show_taxon_concept_serializer_cites.rb b/app/serializers/species/show_taxon_concept_serializer_cites.rb index a17b5bf3bf..4374a8dac8 100644 --- a/app/serializers/species/show_taxon_concept_serializer_cites.rb +++ b/app/serializers/species/show_taxon_concept_serializer_cites.rb @@ -10,23 +10,15 @@ class Species::ShowTaxonConceptSerializerCites < Species::ShowTaxonConceptSerial has_many :eu_decisions, :serializer => Species::EuDecisionSerializer def include_distribution_references? - @options[:mobile].blank? + @options[:trimmed].blank? end def include_standard_references? - @options[:mobile].blank? - end - - def include_eu_listing_changes? - @options[:mobile].blank? + @options[:trimmed].blank? end def include_taxon_concept_references? - @options[:mobile].blank? - end - - def include_cites_listing_changes? - @options[:mobile].blank? + @options[:trimmed].blank? end def quotas diff --git a/app/serializers/species/show_taxon_concept_serializer_cms.rb b/app/serializers/species/show_taxon_concept_serializer_cms.rb index 5d267d43df..206ff96b50 100644 --- a/app/serializers/species/show_taxon_concept_serializer_cms.rb +++ b/app/serializers/species/show_taxon_concept_serializer_cms.rb @@ -2,23 +2,23 @@ class Species::ShowTaxonConceptSerializerCms < Species::ShowTaxonConceptSerializ attributes :cms_listing has_many :cms_listing_changes, :serializer => Species::ListingChangeSerializer, - :key => :cms_listings + :key => :cms_listings, trimmed: @options[:trimmed] has_many :cms_instruments, :serializer => Species::CmsInstrumentsSerializer def include_standard_references? - @options[:mobile].blank? + @options[:trimmed].blank? end def include_taxon_concept_references? - @options[:mobile].blank? + @options[:trimmed].blank? end def include_distribution_references? - @options[:mobile].blank? + @options[:trimmed].blank? end def include_cms_instruments? - @options[:mobile].blank? + @options[:trimmed].blank? end def cms_listing_changes From 88b58b91ad16726bda29ebd1a39ed65f391d3ee1 Mon Sep 17 00:00:00 2001 From: lucacug Date: Mon, 15 Aug 2022 22:41:33 +0100 Subject: [PATCH 11/15] fix: conditionally include attributes in serializer to match mobile data structure --- .../cites_listing_change_serializer.rb | 25 +++++++++++++ .../species/cites_suspension_serializer.rb | 17 +++++---- .../species/eu_decision_serializer.rb | 31 +++++++++------- .../species/eu_listing_change_serializer.rb | 15 ++++++++ app/serializers/species/quota_serializer.rb | 35 ++++++++++++++----- .../species/show_taxon_concept_serializer.rb | 15 +++++--- .../show_taxon_concept_serializer_cites.rb | 9 +++-- .../show_taxon_concept_serializer_cms.rb | 15 ++++---- 8 files changed, 119 insertions(+), 43 deletions(-) diff --git a/app/serializers/species/cites_listing_change_serializer.rb b/app/serializers/species/cites_listing_change_serializer.rb index 9db5d68c27..1c583ac1a8 100644 --- a/app/serializers/species/cites_listing_change_serializer.rb +++ b/app/serializers/species/cites_listing_change_serializer.rb @@ -3,6 +3,31 @@ class Species::CitesListingChangeSerializer < Species::ListingChangeSerializer :hash_full_note_en, :hash_display, :nomenclature_note_en, :nomenclature_note_fr, :nomenclature_note_es + def include_is_addition? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + + def include_hash_full_note_en? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + + def include_hash_display? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + + def include_nomenclature_note_fr? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + + def include_nomenclature_note_es? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + def change_type if object.change_type_name == ChangeType::RESERVATION_WITHDRAWAL "w" diff --git a/app/serializers/species/cites_suspension_serializer.rb b/app/serializers/species/cites_suspension_serializer.rb index e03c28d517..dec7c5949d 100644 --- a/app/serializers/species/cites_suspension_serializer.rb +++ b/app/serializers/species/cites_suspension_serializer.rb @@ -7,22 +7,25 @@ class Species::CitesSuspensionSerializer < ActiveModel::Serializer :start_notification def geo_entity - object['geo_entity_en'] + @options[:trimmed] == 'true' ? object['geo_entity_en'].except('type') : object['geo_entity_en'] end def start_notification - object['start_notification'] + @options[:trimmed] == 'true' ? object['start_notification'].except('date') : object['start_notification'] end def include_nomenclature_note_fr? - @options[:trimmed].blank? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' end def include_nomenclature_note_es? - @options[:trimmed].blank? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' end - - def include_applies_to_import? - @options[:trimmed].blank? + + def include_subspecies_info? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' end end diff --git a/app/serializers/species/eu_decision_serializer.rb b/app/serializers/species/eu_decision_serializer.rb index 6ea692f200..c42b9101de 100644 --- a/app/serializers/species/eu_decision_serializer.rb +++ b/app/serializers/species/eu_decision_serializer.rb @@ -11,20 +11,35 @@ class Species::EuDecisionSerializer < ActiveModel::Serializer { :original_start_date_formatted => :original_start_date }, :private_url + def include_subspecies_info? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + + def include_nomenclature_note_fr? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + + def include_nomenclature_note_es? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + def eu_decision_type - object['eu_decision_type'] + @options[:trimmed] == 'true' ? object['eu_decision_type'].slice('name') : object['eu_decision_type'] end def srg_history - object['srg_history'] + @options[:trimmed] == 'true' ? object['srg_history'].except('description') : object['srg_history'] end def geo_entity - object['geo_entity_en'] + @options[:trimmed] == 'true' ? object['geo_entity_en'].except('type') : object['geo_entity_en'] end def start_event - object['start_event'] + @options[:trimmed] == 'true' ? object['start_event'].except('date') : object['start_event'] end def source @@ -38,12 +53,4 @@ def term def private_url scope.current_user ? object['private_url'] : nil end - - def include_nomenclature_note_fr? - @options[:trimmed].blank? - end - - def include_nomenclature_note_es? - @options[:trimmed].blank? - end end diff --git a/app/serializers/species/eu_listing_change_serializer.rb b/app/serializers/species/eu_listing_change_serializer.rb index 8eaa1946bf..c417d5031e 100644 --- a/app/serializers/species/eu_listing_change_serializer.rb +++ b/app/serializers/species/eu_listing_change_serializer.rb @@ -4,6 +4,21 @@ class Species::EuListingChangeSerializer < Species::ListingChangeSerializer :hash_full_note_en, :hash_display, :nomenclature_note_en, :nomenclature_note_fr, :nomenclature_note_es + def include_change_type_class? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + + def include_hash_full_note_en? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + + def include_hash_display? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + def change_type if object.change_type_name == ChangeType::RESERVATION_WITHDRAWAL "w" diff --git a/app/serializers/species/quota_serializer.rb b/app/serializers/species/quota_serializer.rb index d0d084fd7f..076ea6259e 100644 --- a/app/serializers/species/quota_serializer.rb +++ b/app/serializers/species/quota_serializer.rb @@ -5,8 +5,33 @@ class Species::QuotaSerializer < ActiveModel::Serializer :geo_entity, :unit + def include_nomenclature_note_fr? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + + def include_nomenclature_note_es? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + + def include_public_display? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + + def include_subspecies_info? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + + def include_publication_date_formatted? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + def geo_entity - object['geo_entity_en'] + @options[:trimmed] == 'true' ? object['geo_entity_en'].except('type') : object['geo_entity_en'] end def unit @@ -16,12 +41,4 @@ def unit def quota object['quota_for_display'] end - - def include_nomenclature_note_fr? - @options[:trimmed].blank? - end - - def include_nomenclature_note_es? - @options[:trimmed].blank? - end end diff --git a/app/serializers/species/show_taxon_concept_serializer.rb b/app/serializers/species/show_taxon_concept_serializer.rb index 0df0742c03..fba3e3bd12 100644 --- a/app/serializers/species/show_taxon_concept_serializer.rb +++ b/app/serializers/species/show_taxon_concept_serializer.rb @@ -11,11 +11,18 @@ class Species::ShowTaxonConceptSerializer < ActiveModel::Serializer :key => :references def include_parent_id? - @options[:trimmed].blank? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' end def include_nomenclature_notification? - @options[:trimmed].blank? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + + def include_subspecies? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' end def rank_name @@ -98,7 +105,7 @@ def distributions_with_tags_and_references end def distributions - @options[:trimmed].blank? ? distributions_with_tags_and_references : distributions_with_tags_and_references_trimmed + @options[:trimmed] == 'true' ? distributions_with_tags_and_references_trimmed : distributions_with_tags_and_references end def distributions_with_tags_and_references_trimmed @@ -120,7 +127,7 @@ def standard_references end def distribution_references - @options[:trimmed].blank? ? distributions_with_tags_and_references : distributions_with_tags_and_references_trimmed + @options[:trimmed] == 'true' ? distributions_with_tags_and_references_trimmed : distributions_with_tags_and_references end def cache_key diff --git a/app/serializers/species/show_taxon_concept_serializer_cites.rb b/app/serializers/species/show_taxon_concept_serializer_cites.rb index 4374a8dac8..897050ce89 100644 --- a/app/serializers/species/show_taxon_concept_serializer_cites.rb +++ b/app/serializers/species/show_taxon_concept_serializer_cites.rb @@ -10,15 +10,18 @@ class Species::ShowTaxonConceptSerializerCites < Species::ShowTaxonConceptSerial has_many :eu_decisions, :serializer => Species::EuDecisionSerializer def include_distribution_references? - @options[:trimmed].blank? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' end def include_standard_references? - @options[:trimmed].blank? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' end def include_taxon_concept_references? - @options[:trimmed].blank? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' end def quotas diff --git a/app/serializers/species/show_taxon_concept_serializer_cms.rb b/app/serializers/species/show_taxon_concept_serializer_cms.rb index 206ff96b50..d95f262e2a 100644 --- a/app/serializers/species/show_taxon_concept_serializer_cms.rb +++ b/app/serializers/species/show_taxon_concept_serializer_cms.rb @@ -2,23 +2,22 @@ class Species::ShowTaxonConceptSerializerCms < Species::ShowTaxonConceptSerializ attributes :cms_listing has_many :cms_listing_changes, :serializer => Species::ListingChangeSerializer, - :key => :cms_listings, trimmed: @options[:trimmed] + :key => :cms_listings has_many :cms_instruments, :serializer => Species::CmsInstrumentsSerializer def include_standard_references? - @options[:trimmed].blank? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' end def include_taxon_concept_references? - @options[:trimmed].blank? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' end def include_distribution_references? - @options[:trimmed].blank? - end - - def include_cms_instruments? - @options[:trimmed].blank? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' end def cms_listing_changes From 4f12f69c591916daa656fd6bcb9b870f3a64f9cf Mon Sep 17 00:00:00 2001 From: lucacug Date: Tue, 23 Aug 2022 17:48:06 +0100 Subject: [PATCH 12/15] fix: remove further unused attributes in the mobile trimmed version and reinstatiate those needed for the notes --- .../cites_listing_change_serializer.rb | 10 ---------- .../species/cites_suspension_serializer.rb | 2 +- .../species/eu_decision_serializer.rb | 14 ++++++++++++-- .../species/eu_listing_change_serializer.rb | 4 ++-- .../species/listing_change_serializer.rb | 13 ++++--------- app/serializers/species/quota_serializer.rb | 2 +- .../species/show_taxon_concept_serializer.rb | 19 +++++++++++++++++-- .../show_taxon_concept_serializer_cites.rb | 10 ++++++++++ 8 files changed, 47 insertions(+), 27 deletions(-) diff --git a/app/serializers/species/cites_listing_change_serializer.rb b/app/serializers/species/cites_listing_change_serializer.rb index 1c583ac1a8..4f50a0bc73 100644 --- a/app/serializers/species/cites_listing_change_serializer.rb +++ b/app/serializers/species/cites_listing_change_serializer.rb @@ -8,16 +8,6 @@ def include_is_addition? @options[:trimmed] == 'false' end - def include_hash_full_note_en? - return true unless @options[:trimmed] - @options[:trimmed] == 'false' - end - - def include_hash_display? - return true unless @options[:trimmed] - @options[:trimmed] == 'false' - end - def include_nomenclature_note_fr? return true unless @options[:trimmed] @options[:trimmed] == 'false' diff --git a/app/serializers/species/cites_suspension_serializer.rb b/app/serializers/species/cites_suspension_serializer.rb index dec7c5949d..4feb269bcc 100644 --- a/app/serializers/species/cites_suspension_serializer.rb +++ b/app/serializers/species/cites_suspension_serializer.rb @@ -7,7 +7,7 @@ class Species::CitesSuspensionSerializer < ActiveModel::Serializer :start_notification def geo_entity - @options[:trimmed] == 'true' ? object['geo_entity_en'].except('type') : object['geo_entity_en'] + @options[:trimmed] == 'true' ? object['geo_entity_en'].slice('iso_code2') : object['geo_entity_en'] end def start_notification diff --git a/app/serializers/species/eu_decision_serializer.rb b/app/serializers/species/eu_decision_serializer.rb index fda6566d74..d02e132964 100644 --- a/app/serializers/species/eu_decision_serializer.rb +++ b/app/serializers/species/eu_decision_serializer.rb @@ -27,6 +27,16 @@ def include_nomenclature_note_es? @options[:trimmed] == 'false' end + def include_private_url? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + + def include_intersessional_decision_id? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + def eu_decision_type @options[:trimmed] == 'true' ? object['eu_decision_type'].slice('name') : object['eu_decision_type'] end @@ -36,7 +46,7 @@ def srg_history end def geo_entity - @options[:trimmed] == 'true' ? object['geo_entity_en'].except('type') : object['geo_entity_en'] + @options[:trimmed] == 'true' ? object['geo_entity_en'].slice('iso_code2') : object['geo_entity_en'] end def start_event @@ -48,7 +58,7 @@ def source end def term - object['term_en'] + @options[:trimmed] == 'true' ? object['term_en'].slice('name') : object['term_en'] end def private_url diff --git a/app/serializers/species/eu_listing_change_serializer.rb b/app/serializers/species/eu_listing_change_serializer.rb index c417d5031e..1140ae49f9 100644 --- a/app/serializers/species/eu_listing_change_serializer.rb +++ b/app/serializers/species/eu_listing_change_serializer.rb @@ -9,12 +9,12 @@ def include_change_type_class? @options[:trimmed] == 'false' end - def include_hash_full_note_en? + def include_nomenclature_note_fr? return true unless @options[:trimmed] @options[:trimmed] == 'false' end - def include_hash_display? + def include_nomenclature_note_es? return true unless @options[:trimmed] @options[:trimmed] == 'false' end diff --git a/app/serializers/species/listing_change_serializer.rb b/app/serializers/species/listing_change_serializer.rb index 3bd50874d5..a24b6b1a7d 100644 --- a/app/serializers/species/listing_change_serializer.rb +++ b/app/serializers/species/listing_change_serializer.rb @@ -3,15 +3,10 @@ class Species::ListingChangeSerializer < ActiveModel::Serializer :effective_at_formatted, :short_note_en, :full_note_en, :auto_note, :is_inclusion, :subspecies_info, :inherited_full_note_en, :inherited_short_note_en - def include_is_inclusion? - return true unless @options[:trimmed] - @options[:trimmed] == 'false' - end - - def include_subspecies_info? - return true unless @options[:trimmed] - @options[:trimmed] == 'false' - end + def include_subspecies_info? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end def is_inclusion object.inclusion_taxon_concept_id diff --git a/app/serializers/species/quota_serializer.rb b/app/serializers/species/quota_serializer.rb index 076ea6259e..83eb44dba9 100644 --- a/app/serializers/species/quota_serializer.rb +++ b/app/serializers/species/quota_serializer.rb @@ -31,7 +31,7 @@ def include_publication_date_formatted? end def geo_entity - @options[:trimmed] == 'true' ? object['geo_entity_en'].except('type') : object['geo_entity_en'] + @options[:trimmed] == 'true' ? object['geo_entity_en'].slice('iso_code2') : object['geo_entity_en'] end def unit diff --git a/app/serializers/species/show_taxon_concept_serializer.rb b/app/serializers/species/show_taxon_concept_serializer.rb index fba3e3bd12..179c237a0e 100644 --- a/app/serializers/species/show_taxon_concept_serializer.rb +++ b/app/serializers/species/show_taxon_concept_serializer.rb @@ -25,6 +25,21 @@ def include_subspecies? @options[:trimmed] == 'false' end + def include_kingdom_name? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + + def include_species_name? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + + def include_rank_name? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + def rank_name object.data['rank_name'] end @@ -111,8 +126,8 @@ def distributions def distributions_with_tags_and_references_trimmed Distribution.from('api_distributions_view distributions'). where(taxon_concept_id: object.id). - select("name_en AS country, iso_code2, ARRAY_TO_STRING(tags, ',') AS tags_list"). - order('name_en').all + select("iso_code2, ARRAY_TO_STRING(tags, ',') AS tags_list"). + order('iso_code2').all end def subspecies diff --git a/app/serializers/species/show_taxon_concept_serializer_cites.rb b/app/serializers/species/show_taxon_concept_serializer_cites.rb index d2e54f82c6..7cfd4f67e6 100644 --- a/app/serializers/species/show_taxon_concept_serializer_cites.rb +++ b/app/serializers/species/show_taxon_concept_serializer_cites.rb @@ -24,6 +24,16 @@ def include_taxon_concept_references? @options[:trimmed] == 'false' end + def include_cites_listing? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + + def include_eu_listing? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + def quotas Quota.from('api_cites_quotas_view trade_restrictions'). where(" From 4239d928f6011ebf4b53a74c9a850a8cba6cba98 Mon Sep 17 00:00:00 2001 From: lucacug Date: Wed, 24 Aug 2022 22:04:48 +0100 Subject: [PATCH 13/15] fix: remove name_status and cms _listin attributes from response --- app/serializers/species/show_taxon_concept_serializer.rb | 5 +++++ app/serializers/species/show_taxon_concept_serializer_cms.rb | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/app/serializers/species/show_taxon_concept_serializer.rb b/app/serializers/species/show_taxon_concept_serializer.rb index 179c237a0e..60fa0679d3 100644 --- a/app/serializers/species/show_taxon_concept_serializer.rb +++ b/app/serializers/species/show_taxon_concept_serializer.rb @@ -40,6 +40,11 @@ def include_rank_name? @options[:trimmed] == 'false' end + def include_name_status? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + def rank_name object.data['rank_name'] end diff --git a/app/serializers/species/show_taxon_concept_serializer_cms.rb b/app/serializers/species/show_taxon_concept_serializer_cms.rb index d95f262e2a..60aff1f8ff 100644 --- a/app/serializers/species/show_taxon_concept_serializer_cms.rb +++ b/app/serializers/species/show_taxon_concept_serializer_cms.rb @@ -20,6 +20,11 @@ def include_distribution_references? @options[:trimmed] == 'false' end + def include_cms_listing? + return true unless @options[:trimmed] + @options[:trimmed] == 'false' + end + def cms_listing_changes MCmsListingChange.from('cms_listing_changes_mview listing_changes_mview'). where( From aaba632cbd676913ed8eed3f48672d68b0bf77bb Mon Sep 17 00:00:00 2001 From: roshan-mathewtech Date: Tue, 20 Sep 2022 13:17:46 +0100 Subject: [PATCH 14/15] Bring bacl public_display and subspecies_infor to trimmed version --- app/serializers/species/cites_suspension_serializer.rb | 4 ---- app/serializers/species/eu_decision_serializer.rb | 5 ----- app/serializers/species/listing_change_serializer.rb | 5 ----- app/serializers/species/quota_serializer.rb | 10 ---------- 4 files changed, 24 deletions(-) diff --git a/app/serializers/species/cites_suspension_serializer.rb b/app/serializers/species/cites_suspension_serializer.rb index 4feb269bcc..4485b7badc 100644 --- a/app/serializers/species/cites_suspension_serializer.rb +++ b/app/serializers/species/cites_suspension_serializer.rb @@ -24,8 +24,4 @@ def include_nomenclature_note_es? @options[:trimmed] == 'false' end - def include_subspecies_info? - return true unless @options[:trimmed] - @options[:trimmed] == 'false' - end end diff --git a/app/serializers/species/eu_decision_serializer.rb b/app/serializers/species/eu_decision_serializer.rb index d02e132964..672646d0fa 100644 --- a/app/serializers/species/eu_decision_serializer.rb +++ b/app/serializers/species/eu_decision_serializer.rb @@ -12,11 +12,6 @@ class Species::EuDecisionSerializer < ActiveModel::Serializer :private_url, :intersessional_decision_id - def include_subspecies_info? - return true unless @options[:trimmed] - @options[:trimmed] == 'false' - end - def include_nomenclature_note_fr? return true unless @options[:trimmed] @options[:trimmed] == 'false' diff --git a/app/serializers/species/listing_change_serializer.rb b/app/serializers/species/listing_change_serializer.rb index a24b6b1a7d..ce273ca2ff 100644 --- a/app/serializers/species/listing_change_serializer.rb +++ b/app/serializers/species/listing_change_serializer.rb @@ -3,11 +3,6 @@ class Species::ListingChangeSerializer < ActiveModel::Serializer :effective_at_formatted, :short_note_en, :full_note_en, :auto_note, :is_inclusion, :subspecies_info, :inherited_full_note_en, :inherited_short_note_en - def include_subspecies_info? - return true unless @options[:trimmed] - @options[:trimmed] == 'false' - end - def is_inclusion object.inclusion_taxon_concept_id end diff --git a/app/serializers/species/quota_serializer.rb b/app/serializers/species/quota_serializer.rb index 83eb44dba9..e7e99164f5 100644 --- a/app/serializers/species/quota_serializer.rb +++ b/app/serializers/species/quota_serializer.rb @@ -15,16 +15,6 @@ def include_nomenclature_note_es? @options[:trimmed] == 'false' end - def include_public_display? - return true unless @options[:trimmed] - @options[:trimmed] == 'false' - end - - def include_subspecies_info? - return true unless @options[:trimmed] - @options[:trimmed] == 'false' - end - def include_publication_date_formatted? return true unless @options[:trimmed] @options[:trimmed] == 'false' From cc897faa52389edf8c28f4b7aa1950543a4a3958 Mon Sep 17 00:00:00 2001 From: lucacug Date: Tue, 4 Oct 2022 11:40:44 +0100 Subject: [PATCH 15/15] chore: update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 573986bc1f..3b531900b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### 1.9.0 + +* Add parameter to taxon concept show API internal endpoint to trimmed response for the mobile app + ### 1.8.6 * Schedule rebuild job to run daily on staging