mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-18 07:01:58 +08:00
29 lines
884 B
Ruby
29 lines
884 B
Ruby
# frozen_string_literal: true
|
|
|
|
module ExperimentsHelper
|
|
def experiments_view_mode(project)
|
|
params[:view_mode] == 'archived' ? 'archived' : 'active'
|
|
end
|
|
|
|
def grouped_by_prj(experiments)
|
|
ungrouped_experiments = experiments.joins(:project)
|
|
.select('projects.name as project_name,
|
|
projects.archived as project_archived,
|
|
experiments.*')
|
|
ungrouped_experiments.group_by { |i| [i[:project_name]] }.map do |group, exps|
|
|
{
|
|
project_name: group[0],
|
|
project_archived: exps[0]&.project_archived,
|
|
experiments: exps
|
|
}
|
|
end
|
|
end
|
|
|
|
def experiment_archived_on(experiment)
|
|
if experiment.archived?
|
|
experiment.archived_on
|
|
elsif experiment.project.archived?
|
|
experiment.project.archived_on
|
|
end
|
|
end
|
|
end
|