Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: mappings statistics slices support #78

Merged
merged 3 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions controllers/mappings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ class MappingsController < ApplicationController
.each do |m|
persistent_counts[m.ontologies.first] = m.count
end
ont_acronyms = restricted_ontologies_to_acronyms(params)
persistent_counts = persistent_counts.select { |key, _| ont_acronyms.include?(key) || key.start_with?("http://") }
reply persistent_counts
end

Expand Down
3 changes: 3 additions & 0 deletions test/controllers/test_mappings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def test_mappings_file_load
commun_created_mappings_test(created, mapping_term_a, mapping_term_b, relations)
end


private

def commun_created_mappings_test(created, mapping_term_a, mapping_term_b, relations)
Expand Down Expand Up @@ -423,4 +424,6 @@ def build_mappings_hash
end
[mappings, mapping_ont_a, mapping_ont_b, mapping_term_a, mapping_term_b, relations]
end


end
25 changes: 25 additions & 0 deletions test/helpers/test_slices_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,31 @@ def test_search_slices
assert results.all? {|r| group_ids.include?(r["links"]["ontology"])}
end

def test_mappings_slices
LinkedData::Mappings.create_mapping_counts(Logger.new(TestLogFile.new))

get "/mappings/statistics/ontologies/"

expected_result_without_slice = ["PARSED-0",
"PARSED-1",
"http://data.bioontology.org/metadata/ExternalMappings",
"http://data.bioontology.org/metadata/InterportalMappings/agroportal",
"http://data.bioontology.org/metadata/InterportalMappings/ncbo",
"http://data.bioontology.org/metadata/InterportalMappings/sifr"]

assert_equal expected_result_without_slice, MultiJson.load(last_response.body).keys.sort

get "http://#{@@group_acronym}/mappings/statistics/ontologies/"

expected_result_with_slice = ["PARSED-0",
"http://data.bioontology.org/metadata/ExternalMappings",
"http://data.bioontology.org/metadata/InterportalMappings/agroportal",
"http://data.bioontology.org/metadata/InterportalMappings/ncbo",
"http://data.bioontology.org/metadata/InterportalMappings/sifr"]

assert_equal expected_result_with_slice, MultiJson.load(last_response.body).keys.sort
end

private

def self._create_group
Expand Down
Loading