diff --git a/app/controllers/entities_controller.rb b/app/controllers/entities_controller.rb index 96e6880d..b9b1cc7f 100644 --- a/app/controllers/entities_controller.rb +++ b/app/controllers/entities_controller.rb @@ -76,13 +76,7 @@ def show @similar_people = entity.natural_person? ? similar_people(entity) : nil end - raw_records = RAW_DATA_RECORD_REPOSITORY.all_for_entity(entity) - @data_source_names = DATA_SOURCE_REPOSITORY.data_source_names_for_raw_records(raw_records) - - unless @data_source_names.empty? - @newest_raw_record = RAW_DATA_RECORD_REPOSITORY.newest_for_entity_date(entity) - @raw_record_count = raw_records.size - end + @data_source_names = DATA_SOURCE_REPOSITORY.data_source_names_for_entity(entity) # Conversion @oc_data = get_opencorporates_company_hash(entity, sparse: true) || {} diff --git a/app/repositories/data_source_repository.rb b/app/repositories/data_source_repository.rb index 6391c5ad..0d407aa1 100644 --- a/app/repositories/data_source_repository.rb +++ b/app/repositories/data_source_repository.rb @@ -24,6 +24,13 @@ def where_overview_present all.filter { |data_source| data_source.overview.present? } end + def data_source_names_for_entity(entity) + [ + entity.relationships_as_source, + entity.relationships_as_target + ].flatten.compact.map(&:provenance).map(&:source_name).uniq.sort + end + def data_source_names_for_raw_records(raw_records) datasource_names = raw_records.map do |raw_record| case raw_record diff --git a/app/views/entities/show.html.haml b/app/views/entities/show.html.haml index 2c0ec27e..beedb5e7 100644 --- a/app/views/entities/show.html.haml +++ b/app/views/entities/show.html.haml @@ -132,10 +132,8 @@ %ul %li %p= @data_source_names.to_sentence - %p.meta-secondary - = t('entities.provenance.latest_data', date: @newest_raw_record.to_date) %li - = link_to(t('entities.provenance.detail', count: @raw_record_count), raw_entity_path(@sentity.id)) + = link_to(t('entities.provenance.detail'), raw_entity_path(@sentity.id)) - if @oc_data[:restricted_for_marketing] diff --git a/config/locales/en.yml b/config/locales/en.yml index 97f6544b..15568969 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -63,7 +63,7 @@ en: latest_data: 'Latest data: %{date}' detail: one: 'See the original source record' - other: 'See the %{count} original source records' + other: 'See the original source records' data_sources: show: data_availability_title: Data availability and license