diff --git a/app/services/guidance_service.rb b/app/services/guidance_service.rb index da115f0..929b3c7 100644 --- a/app/services/guidance_service.rb +++ b/app/services/guidance_service.rb @@ -20,9 +20,22 @@ end return @orgs end + def any?(org:nil, question:nil) - if org.nil? && question.nil? - return hashified_annotations? || hashified_guidance_groups? + if org.nil? + if question.nil? + return hashified_annotations? || hashified_guidance_groups? + end + if question.present? + # check each annotation/guidance group for a response to this question + # Would be nice not to have to crawl the entire list each time we want to know this + anno = orgs.reduce(false) {|found, o| found || guidance_annotations?(org: o, question: question)} + if !anno + return orgs.reduce(anno) {|found, o| found || guidance_groups_by_theme?(org: o, question: question)} + else + return anno + end + end end return guidance_annotations?(org: org, question: question) || guidance_groups_by_theme?(org: org, question: question) diff --git a/app/views/org_admin/annotations/_show.html.erb b/app/views/org_admin/annotations/_show.html.erb index d5392d9..4e99b1e 100644 --- a/app/views/org_admin/annotations/_show.html.erb +++ b/app/views/org_admin/annotations/_show.html.erb @@ -5,7 +5,6 @@