mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-13 16:45:18 +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)
|
repository = Repository.accessible_by_teams(my_module.experiment.project.team).find_by(id: element_id)
|
||||||
# Check for default set snapshots when repository still exists
|
# Check for default set snapshots when repository still exists
|
||||||
if repository
|
if repository
|
||||||
selected_snapshot = repository.repository_snapshots
|
selected_snapshot = repository.repository_snapshots.where(my_module: my_module).find_by(selected: true)
|
||||||
.joins(repository_rows: { my_module_repository_rows: :my_module })
|
|
||||||
.where(repository_rows: { my_module_repository_rows: { my_module: my_module } })
|
|
||||||
.find_by(selected: true)
|
|
||||||
repository = selected_snapshot if selected_snapshot
|
repository = selected_snapshot if selected_snapshot
|
||||||
end
|
end
|
||||||
repository ||= RepositorySnapshot.joins(my_module: { experiment: :project })
|
repository ||= RepositorySnapshot.joins(my_module: { experiment: :project })
|
||||||
|
|
|
@ -104,7 +104,7 @@ class Report < ApplicationRecord
|
||||||
content = {
|
content = {
|
||||||
'experiments' => [],
|
'experiments' => [],
|
||||||
'tasks' => {},
|
'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|
|
project.experiments.includes(:my_modules).each do |experiment|
|
||||||
content['experiments'].push(experiment.id)
|
content['experiments'].push(experiment.id)
|
||||||
|
|
|
@ -28,8 +28,8 @@ class RepositorySnapshot < RepositoryBase
|
||||||
|
|
||||||
scope :assigned_to_project, lambda { |project|
|
scope :assigned_to_project, lambda { |project|
|
||||||
where(team: project.team)
|
where(team: project.team)
|
||||||
.joins(repository_rows: { my_module_repository_rows: { my_module: { experiment: :project } } })
|
.joins(my_module: { experiment: :project })
|
||||||
.where(repository_rows: { my_module_repository_rows: { my_module: { experiments: { project: project } } } })
|
.where(my_module: { experiments: { project: project } })
|
||||||
}
|
}
|
||||||
|
|
||||||
def self.create_preliminary(repository, my_module, created_by = nil)
|
def self.create_preliminary(repository, my_module, created_by = nil)
|
||||||
|
|
|
@ -13,8 +13,9 @@ module ReportActions
|
||||||
@element_position = 0
|
@element_position = 0
|
||||||
@report = report
|
@report = report
|
||||||
@template_values = template_values
|
@template_values = template_values
|
||||||
@repositories = Repository.accessible_by_teams(report.project.team)
|
@repositories = report.project
|
||||||
.where(id: @content['repositories'])
|
.assigned_repositories_and_snapshots
|
||||||
|
.select { |repository| @content['repositories'].include?(repository.id) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_with_content
|
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)
|
my_module_element = save_element!({ 'my_module_id' => my_module.id }, :my_module, experiment_element)
|
||||||
|
|
||||||
@repositories.each do |repository|
|
@repositories.each do |repository|
|
||||||
|
next unless my_module.live_and_snapshot_repositories_list.pluck(:id).include?(repository.id)
|
||||||
|
|
||||||
save_element!(
|
save_element!(
|
||||||
{ 'my_module_id' => my_module.id, 'repository_id' => repository.id },
|
{ 'my_module_id' => my_module.id, 'repository_id' => repository.id },
|
||||||
:my_module_repository,
|
:my_module_repository,
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
<div class="pull-left table-name">
|
<div class="pull-left table-name">
|
||||||
<% file_link = @obj_filenames.dig(:repositories, repository.id, :file) %>
|
<% file_link = @obj_filenames.dig(:repositories, repository.id, :file) %>
|
||||||
<a href="<%= file_link %>">
|
<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>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
<% if defined? export_all and export_all %>
|
<% if defined? export_all and export_all %>
|
||||||
<% file_link = @obj_filenames.dig(:assets, asset.id, :file) %>
|
<% file_link = @obj_filenames.dig(:assets, asset.id, :file) %>
|
||||||
<a href="<%= file_link %>">
|
<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>
|
</a>
|
||||||
<% else %>
|
<% else %>
|
||||||
<em>
|
<em>
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<div class="pull-left table-name">
|
<div class="pull-left table-name">
|
||||||
<% file_link = @obj_filenames.dig(:tables, table.id, :file) %>
|
<% file_link = @obj_filenames.dig(:tables, table.id, :file) %>
|
||||||
<a href="<%= file_link %>">
|
<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>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<% if defined? export_all and export_all %>
|
<% if defined? export_all and export_all %>
|
||||||
<% file_link = @obj_filenames.dig(:assets, asset.id, :file) %>
|
<% file_link = @obj_filenames.dig(:assets, asset.id, :file) %>
|
||||||
<a href="<%= file_link %>">
|
<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>
|
</a>
|
||||||
<% else %>
|
<% else %>
|
||||||
<em>
|
<em>
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<% if defined? export_all and export_all %>
|
<% if defined? export_all and export_all %>
|
||||||
<% file_link = @obj_filenames.dig(:tables, table.id, :file) %>
|
<% file_link = @obj_filenames.dig(:tables, table.id, :file) %>
|
||||||
<a href="<%= file_link %>">
|
<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>
|
</a>
|
||||||
<% else %>
|
<% else %>
|
||||||
<% if table.try(:name) %>
|
<% if table.try(:name) %>
|
||||||
|
|
Loading…
Add table
Reference in a new issue