scinote-web/app/helpers/experiments_helper.rb

32 lines
928 B
Ruby
Raw Normal View History

2020-09-09 20:17:19 +08:00
# frozen_string_literal: true
module ExperimentsHelper
def experiments_view_mode(project)
return 'archived' if project.archived?
params[:view_mode] == 'archived' ? 'archived' : 'active'
end
2020-09-09 20:17:19 +08:00
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
2021-01-12 22:15:57 +08:00
def experiment_archived_on(experiment)
if experiment.archived?
experiment.archived_on
elsif experiment.project.archived?
experiment.project.archived_on
end
end
2020-09-09 20:17:19 +08:00
end