Skip to content

Commit

Permalink
Feature: mappings statistics slices support (#78)
Browse files Browse the repository at this point in the history
* restrict mapping statistics ontologies to the ontologies of the current slice

* add a test for the mappings slices support

* add test for mappings statistics slices support
  • Loading branch information
Bilelkihal authored May 21, 2024
1 parent 5230091 commit 5c03e7e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
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

0 comments on commit 5c03e7e

Please sign in to comment.