mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-11 01:44:34 +08:00
Merge pull request #2722 from okriuchykhin/ok_SCI_4845
Fix missing unshared inventories with snapshots in reports [SCI-4845]
This commit is contained in:
commit
12a8d50098
3 changed files with 5 additions and 5 deletions
|
@ -139,7 +139,7 @@ module ReportsHelper
|
|||
|
||||
def assigned_repositories_in_project_list(project)
|
||||
live_repositories = Repository.assigned_to_project(project)
|
||||
snapshots = RepositorySnapshot.assigned_to_project(project)
|
||||
snapshots = RepositorySnapshot.of_unassigned_from_project(project)
|
||||
|
||||
snapshots.each { |snapshot| snapshot.name = "#{snapshot.name} #{t('projects.reports.index.deleted')}" }
|
||||
(live_repositories + snapshots).sort_by { |r| r.name.downcase }
|
||||
|
|
|
@ -212,7 +212,7 @@ class Project < ApplicationRecord
|
|||
|
||||
def assigned_repositories_and_snapshots
|
||||
live_repositories = Repository.assigned_to_project(self)
|
||||
snapshots = RepositorySnapshot.assigned_to_project(self)
|
||||
snapshots = RepositorySnapshot.of_unassigned_from_project(self)
|
||||
(live_repositories + snapshots).sort_by { |r| r.name.downcase }
|
||||
end
|
||||
|
||||
|
|
|
@ -17,11 +17,11 @@ class RepositorySnapshot < RepositoryBase
|
|||
validates :status, presence: true
|
||||
validate :only_one_selected_for_my_module, if: ->(obj) { obj.changed.include? 'selected' }
|
||||
|
||||
scope :assigned_to_project, lambda { |project|
|
||||
scope :of_unassigned_from_project, lambda { |project|
|
||||
joins(my_module: { experiment: :project })
|
||||
.where('experiments.project_id = ?', project.id)
|
||||
.where(my_modules: { experiments: { project: project } })
|
||||
.left_outer_joins(:original_repository)
|
||||
.where(original_repositories_repositories: { id: nil })
|
||||
.where.not(original_repository: Repository.assigned_to_project(project))
|
||||
.select('DISTINCT ON ("repositories"."parent_id") "repositories".*')
|
||||
.order(:parent_id, updated_at: :desc)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue