mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-10 17:36:33 +08:00
Improve code styling [SCI-4738]
This commit is contained in:
parent
86b2eea383
commit
166a0ddd34
5 changed files with 13 additions and 15 deletions
|
@ -138,8 +138,8 @@ module ReportsHelper
|
|||
end
|
||||
|
||||
def assigned_repositories_in_project_list(project)
|
||||
live_repositories = Repository.assigned_in_project(project)
|
||||
snapshots = RepositorySnapshot.assigned_in_project(project)
|
||||
live_repositories = Repository.assigned_to_project(project)
|
||||
snapshots = RepositorySnapshot.assigned_to_project(project)
|
||||
|
||||
snapshots.each { |snapshot| snapshot.name = "#{snapshot.name} #{t('projects.reports.index.deleted')}" }
|
||||
(live_repositories + snapshots).sort_by { |r| r.name.downcase }
|
||||
|
|
|
@ -211,8 +211,8 @@ class Project < ApplicationRecord
|
|||
end
|
||||
|
||||
def assigned_repositories_and_snapshots
|
||||
live_repositories = Repository.assigned_in_project(self)
|
||||
snapshots = RepositorySnapshot.assigned_in_project(self)
|
||||
live_repositories = Repository.assigned_to_project(self)
|
||||
snapshots = RepositorySnapshot.assigned_to_project(self)
|
||||
(live_repositories + snapshots).sort_by { |r| r.name.downcase }
|
||||
end
|
||||
|
||||
|
|
|
@ -131,12 +131,10 @@ class Report < ApplicationRecord
|
|||
result_children)
|
||||
end
|
||||
|
||||
module_children += gen_element_content(my_module, nil, 'my_module_activity', true, 'asc')
|
||||
|
||||
repositories = project.assigned_repositories_and_snapshots
|
||||
|
||||
module_children += gen_element_content(my_module, nil, 'my_module_activity', true, 'asc')
|
||||
module_children += gen_element_content(my_module, repositories, 'my_module_repository', true, 'asc')
|
||||
|
||||
modules += gen_element_content(my_module, nil, 'my_module', true, nil, module_children)
|
||||
end
|
||||
|
||||
|
|
|
@ -36,6 +36,12 @@ class Repository < RepositoryBase
|
|||
.distinct
|
||||
}
|
||||
|
||||
scope :assigned_to_project, lambda { |project|
|
||||
accessible_by_teams(project.team)
|
||||
.joins(repository_rows: { my_module_repository_rows: { my_module: { experiment: :project } } })
|
||||
.where(repository_rows: { my_module_repository_rows: { my_module: { experiments: { project: project } } } })
|
||||
}
|
||||
|
||||
def self.within_global_limits?
|
||||
return true unless Rails.configuration.x.global_repositories_limit.positive?
|
||||
|
||||
|
@ -83,12 +89,6 @@ class Repository < RepositoryBase
|
|||
end
|
||||
end
|
||||
|
||||
def self.assigned_in_project(project)
|
||||
accessible_by_teams(project.team)
|
||||
.joins(repository_rows: { my_module_repository_rows: { my_module: { experiment: :project } } })
|
||||
.where(repository_rows: { my_module_repository_rows: { my_module: { experiments: { project: project } } } })
|
||||
end
|
||||
|
||||
def default_columns_count
|
||||
Constants::REPOSITORY_TABLE_DEFAULT_STATE['length']
|
||||
end
|
||||
|
|
|
@ -15,14 +15,14 @@ class RepositorySnapshot < RepositoryBase
|
|||
validates :status, presence: true
|
||||
validate :only_one_selected_for_my_module, if: ->(obj) { obj.changed.include? :selected }
|
||||
|
||||
def self.assigned_in_project(project)
|
||||
scope :assigned_to_project, lambda { |project|
|
||||
joins(my_module: { experiment: :project })
|
||||
.where('experiments.project_id = ?', project.id)
|
||||
.left_outer_joins(:original_repository)
|
||||
.where(original_repositories_repositories: { id: nil })
|
||||
.select('DISTINCT ON ("repositories"."parent_id") "repositories".*')
|
||||
.order(:parent_id, updated_at: :desc)
|
||||
end
|
||||
}
|
||||
|
||||
def default_columns_count
|
||||
Constants::REPOSITORY_SNAPSHOT_TABLE_DEFAULT_STATE['length']
|
||||
|
|
Loading…
Reference in a new issue