Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include observation units in the statistics dashboards #2126

Merged
merged 3 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/helpers/isa_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module IsaHelper
'Investigation' => '#D6FF00',
'Study' => '#96ED29',
'Assay' =>'#52D155',
'ObservationUnit' => '#40A040',
'Publication' => '#CBB8FF',
'DataFile' => '#FFC382',
'Document' => '#D5C8A8',
Expand Down
1 change: 1 addition & 0 deletions app/models/programme.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Programme < ApplicationRecord
has_many :investigations, -> { distinct }, through: :projects
has_many :studies, -> { distinct }, through: :investigations
has_many :assays, -> { distinct }, through: :studies
has_many :observation_units, -> { distinct }, through: :studies
%i[data_files documents models sops presentations events publications samples workflows collections].each do |type|
has_many type, -> { distinct }, through: :projects
end
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@
get :reject_activation_confirmation
get :storage_report
end
resources :people, :projects, :institutions, :investigations, :studies, :assays, :samples,
resources :people, :projects, :institutions, :investigations, :studies, :assays, :observation_units, :samples,
:data_files, :models, :sops, :workflows, :presentations, :documents, :events, :publications, :organisms, :human_diseases, :collections, only: [:index]
concerns :has_dashboard, controller: :programme_stats
end
Expand Down
2 changes: 1 addition & 1 deletion lib/seek/stats/dashboard_stats.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def scoped_assets
end

def scoped_isa
@isa ||= Investigation.all + Study.all + Assay.all
@isa ||= Investigation.all + Study.all + Assay.all + ObservationUnit.all
end

def project_scope
Expand Down
2 changes: 1 addition & 1 deletion lib/seek/stats/programme_dashboard_stats.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def scoped_assets
end

def scoped_isa
@isa ||= programme.investigations + programme.studies + programme.assays
@isa ||= programme.investigations + programme.studies + programme.assays + programme.observation_units
end

def project_scope
Expand Down
2 changes: 1 addition & 1 deletion lib/seek/stats/project_dashboard_stats.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def scoped_assets
end

def scoped_isa
@isa ||= project.investigations + project.studies + project.assays
@isa ||= project.investigations + project.studies + project.assays + project.observation_units
end

def project_scope
Expand Down
4 changes: 3 additions & 1 deletion test/unit/dashboard_stats_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,16 @@ class DashboardStatsTest < ActiveSupport::TestCase
study = FactoryBot.create(:study, investigation: investigation, contributor: person)
Assay.delete_all
assay = FactoryBot.create(:assay, study: study, contributor: person)
ObservationUnit.delete_all
obs_unit = FactoryBot.create(:observation_unit, study: study, contributor: person)

instance_stats = Seek::Stats::DashboardStats.new
# Reload to refresh associations
project_stats = Seek::Stats::ProjectDashboardStats.new(project.reload)
programme_stats = Seek::Stats::ProgrammeDashboardStats.new(programme.reload)

opts = [2.days.ago, 2.days.from_now, 'month']
types = [DataFile, Sop, Model, Publication, Presentation, Document, Workflow, Collection, Investigation, Study, Assay]
types = [DataFile, Sop, Model, Publication, Presentation, Document, Workflow, Collection, Investigation, Study, Assay, ObservationUnit]

c = instance_stats.contributions(*opts)
(types + [Project, Programme]).each do |t|
Expand Down