mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-08 14:15:35 +08:00
Fix repository snapshots for export all [SCI-5776]
This commit is contained in:
parent
7313b5fa16
commit
85a5cca98a
9 changed files with 14 additions and 14 deletions
|
@ -121,10 +121,7 @@ module ReportsHelper
|
|||
repository = Repository.accessible_by_teams(my_module.experiment.project.team).find_by(id: element_id)
|
||||
# Check for default set snapshots when repository still exists
|
||||
if repository
|
||||
selected_snapshot = repository.repository_snapshots
|
||||
.joins(repository_rows: { my_module_repository_rows: :my_module })
|
||||
.where(repository_rows: { my_module_repository_rows: { my_module: my_module } })
|
||||
.find_by(selected: true)
|
||||
selected_snapshot = repository.repository_snapshots.where(my_module: my_module).find_by(selected: true)
|
||||
repository = selected_snapshot if selected_snapshot
|
||||
end
|
||||
repository ||= RepositorySnapshot.joins(my_module: { experiment: :project })
|
||||
|
|
|
@ -104,7 +104,7 @@ class Report < ApplicationRecord
|
|||
content = {
|
||||
'experiments' => [],
|
||||
'tasks' => {},
|
||||
'repositories' => Repository.accessible_by_teams(project.team).pluck(:id)
|
||||
'repositories' => project.assigned_repositories_and_snapshots.pluck(:id)
|
||||
}
|
||||
project.experiments.includes(:my_modules).each do |experiment|
|
||||
content['experiments'].push(experiment.id)
|
||||
|
|
|
@ -28,8 +28,8 @@ class RepositorySnapshot < RepositoryBase
|
|||
|
||||
scope :assigned_to_project, lambda { |project|
|
||||
where(team: 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 } } } })
|
||||
.joins(my_module: { experiment: :project })
|
||||
.where(my_module: { experiments: { project: project } })
|
||||
}
|
||||
|
||||
def self.create_preliminary(repository, my_module, created_by = nil)
|
||||
|
|
|
@ -13,8 +13,9 @@ module ReportActions
|
|||
@element_position = 0
|
||||
@report = report
|
||||
@template_values = template_values
|
||||
@repositories = Repository.accessible_by_teams(report.project.team)
|
||||
.where(id: @content['repositories'])
|
||||
@repositories = report.project
|
||||
.assigned_repositories_and_snapshots
|
||||
.select { |repository| @content['repositories'].include?(repository.id) }
|
||||
end
|
||||
|
||||
def save_with_content
|
||||
|
@ -80,6 +81,8 @@ module ReportActions
|
|||
my_module_element = save_element!({ 'my_module_id' => my_module.id }, :my_module, experiment_element)
|
||||
|
||||
@repositories.each do |repository|
|
||||
next unless my_module.live_and_snapshot_repositories_list.pluck(:id).include?(repository.id)
|
||||
|
||||
save_element!(
|
||||
{ 'my_module_id' => my_module.id, 'repository_id' => repository.id },
|
||||
:my_module_repository,
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
<div class="pull-left table-name">
|
||||
<% file_link = @obj_filenames.dig(:repositories, repository.id, :file) %>
|
||||
<a href="<%= file_link %>">
|
||||
<em><%= t('projects.reports.elements.module_repository.table_name', name: file_link&.split('/').last) %></em>
|
||||
<em><%= t('projects.reports.elements.module_repository.table_name', name: file_link&.split('/')&.last) %></em>
|
||||
</a>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
<% if defined? export_all and export_all %>
|
||||
<% file_link = @obj_filenames.dig(:assets, asset.id, :file) %>
|
||||
<a href="<%= file_link %>">
|
||||
<em><%= t("projects.reports.elements.result_asset.file_name", file: file_link&.split('/').last) %></em>
|
||||
<em><%= t("projects.reports.elements.result_asset.file_name", file: file_link&.split('/')&.last) %></em>
|
||||
</a>
|
||||
<% else %>
|
||||
<em>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<div class="pull-left table-name">
|
||||
<% file_link = @obj_filenames.dig(:tables, table.id, :file) %>
|
||||
<a href="<%= file_link %>">
|
||||
<em><%=t "projects.reports.elements.result_table.table_name", name: file_link&.split('/').last %></em>
|
||||
<em><%=t "projects.reports.elements.result_table.table_name", name: file_link&.split('/')&.last %></em>
|
||||
</a>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<% if defined? export_all and export_all %>
|
||||
<% file_link = @obj_filenames.dig(:assets, asset.id, :file) %>
|
||||
<a href="<%= file_link %>">
|
||||
<em><%= t('projects.reports.elements.step_asset.file_name', file: file_link&.split('/').last) %></em>
|
||||
<em><%= t('projects.reports.elements.step_asset.file_name', file: file_link&.split('/')&.last) %></em>
|
||||
</a>
|
||||
<% else %>
|
||||
<em>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<% if defined? export_all and export_all %>
|
||||
<% file_link = @obj_filenames.dig(:tables, table.id, :file) %>
|
||||
<a href="<%= file_link %>">
|
||||
<em><%=t 'projects.reports.elements.step_table.table_name', name: file_link&.split('/').last %></em>
|
||||
<em><%=t 'projects.reports.elements.step_table.table_name', name: file_link&.split('/')&.last %></em>
|
||||
</a>
|
||||
<% else %>
|
||||
<% if table.try(:name) %>
|
||||
|
|
Loading…
Add table
Reference in a new issue