Skip to content

Commit 72cd032

Browse files
optimize mapping page by not doing an API call of each mapping
1 parent 222e01b commit 72cd032

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app/helpers/mappings_helper.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,13 @@ def onts_and_views_for_select
4141

4242
def get_concept_mappings(concept)
4343
mappings = concept.explore.mappings
44+
all_ontologies = LinkedData::Client::Models::Ontology.all(include: "acronym", display_links: false, display_context: false)
4445
# Remove mappings where the destination class exists in an ontology that the logged in user doesn't have permissions to view.
4546
# Workaround for https://github.com/ncbo/ontologies_api/issues/52.
4647
mappings.delete_if do |mapping|
4748
mapping.classes.reject! { |cls| (cls.id == concept.id) && (cls.links['ontology'] == concept.links['ontology']) }
48-
ont = mapping.classes[0].explore.ontology
49-
ont.errors && ont.errors.grep(/Access denied/).any?
49+
ont = mapping.classes[0].links['ontology']
50+
!all_ontologies.map(&:acronym).include?(ont.split('/').last)
5051
end
5152
end
5253

0 commit comments

Comments
 (0)