diff --git a/app/helpers/human_diseases_helper.rb b/app/helpers/human_diseases_helper.rb index e355dd9f0d..14d0b20e33 100644 --- a/app/helpers/human_diseases_helper.rb +++ b/app/helpers/human_diseases_helper.rb @@ -58,19 +58,27 @@ def get_transitive_related_resources(resource, limit = nil) end def get_human_diseases_plot_data() - Rails.cache.fetch('human_diseases_plot_data', expires_in: 12.hours) do - HumanDisease.all.order(:id).map do |c| - { - id: c.id.to_s, - title: c.title, - parent: c.parents.first ? c.parents.first.id.to_s : '', - projects: c.projects.count, - # assays: c.assays.count, # currently not in use - publications: c.publications.count, - models: c.models.count, - data_files: c.data_files.count, - } - end + Rails.cache.fetch('human_diseases_data', expires_in: 12.hours) do + { + tagged: + HumanDisease.all.order(:id).map do |c| + { + id: c.id.to_s, + title: c.title, + parent: c.parents.first ? c.parents.first.id.to_s : '', + projects: c.projects.count, + publications: c.publications.count, + models: c.models.count, + data_files: c.data_files.count, + } + end, + untagged: { + projects: Project.left_outer_joins(:human_diseases).where(human_diseases: { id: nil }).count(), + publications: Publication.left_outer_joins(:human_diseases).where(human_diseases: { id: nil }).count(), + models: Model.where(human_disease: nil).count(), + data_files: DataFile.left_outer_joins(:human_diseases).where(human_diseases: { id: nil }).count(), + }, + } end end end diff --git a/app/views/human_diseases/_overview_plot.html.erb b/app/views/human_diseases/_overview_plot.html.erb index 1725ef9f1c..4cc1690add 100644 --- a/app/views/human_diseases/_overview_plot.html.erb +++ b/app/views/human_diseases/_overview_plot.html.erb @@ -1,5 +1,7 @@ <% - dataframe = get_human_diseases_plot_data() + data = get_human_diseases_plot_data() + tagged = data[:tagged] + untagged = data[:untagged] %>