Skip to content

Commit

Permalink
Show untagged content below disease plot
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristophB committed Jan 26, 2024
1 parent 4fd42da commit c6ab8ee
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 19 deletions.
34 changes: 21 additions & 13 deletions app/helpers/human_diseases_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 12 additions & 6 deletions app/views/human_diseases/_overview_plot.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<%
dataframe = get_human_diseases_plot_data()
data = get_human_diseases_plot_data()
tagged = data[:tagged]
untagged = data[:untagged]
%>

<div class="row hidden-xs hidden-sm">
Expand All @@ -10,6 +12,10 @@
</div>
<div class="panel-body">
<div id="human-disease-graph"></div>
<small class="text-muted">
Untagged:<br>
<%= untagged.map{ |key, value| key.to_s.humanize + ': ' + value.to_s }.join(', ') %>
</small>
</div>
</div>
</div>
Expand All @@ -32,11 +38,11 @@
<% plots.each do |plot| %>
{
type: 'sunburst',
ids: [ <%== dataframe.map{ |c| '"' + c[:id] + '"' }.join(', ') %> ],
labels: [ <%== dataframe.map{ |c| '"' + + '"' }.join(', ') %> ],
parents: [ <%== dataframe.map{ |c| '"' + c[:parent] + '"' }.join(', ') %> ],
values: [ <%== dataframe.map{ |c| c[plot[:key]] }.join(', ') %> ],
hovertext: [ <%== dataframe.map{ |c| '"' + c[:title] + '"' }.join(', ') %> ],
ids: [ <%== tagged.map{ |c| '"' + c[:id] + '"' }.join(', ') %> ],
labels: [ <%== tagged.map{ |c| '"' + + '"' }.join(', ') %> ],
parents: [ <%== tagged.map{ |c| '"' + c[:parent] + '"' }.join(', ') %> ],
values: [ <%== tagged.map{ |c| c[plot[:key]] }.join(', ') %> ],
hovertext: [ <%== tagged.map{ |c| '"' + c[:title] + '"' }.join(', ') %> ],
outsidetextfont: { size: 20, color: '#377eb8' },
leaf: { opacity: 1 },
marker: { line: { width: 2 } },
Expand Down

0 comments on commit c6ab8ee

Please sign in to comment.