Merge pull request #7823 from scinote-eln/develop

Shared task fixes
This commit is contained in:
Martin Artnik 2024-08-28 12:06:41 +02:00 committed by GitHub
commit 88462de1d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 21 additions and 2 deletions

View file

@ -153,7 +153,7 @@ class MyModuleShareableLinksController < ApplicationController
end
def load_repository
@repository = @my_module.assigned_repositories.viewable_by_user(current_user).find_by(id: params[:id])
@repository = @my_module.assigned_repositories.find_by(id: params[:id])
render_404 unless @repository
end

View file

@ -202,6 +202,25 @@ class MyModule < ApplicationRecord
(live_repositories + selected_snapshots).sort_by { |r| r.name.downcase }
end
def live_and_snapshot_repositories_list
snapshots = repository_snapshots.left_outer_joins(:original_repository)
selected_snapshots = snapshots.where(selected: true)
.or(snapshots.where(original_repositories_repositories: { id: nil }))
.or(snapshots.where.not(parent_id: assigned_repositories.select(:id)))
.select('DISTINCT ON ("repositories"."parent_id") "repositories".*')
.select('COUNT(repository_rows.id) AS assigned_rows_count')
.joins(:repository_rows)
.group(:parent_id, :id)
.order(:parent_id, updated_at: :desc)
live_repositories = assigned_repositories
.select('repositories.*, COUNT(DISTINCT repository_rows.id) AS assigned_rows_count')
.where.not(id: repository_snapshots.where(selected: true).select(:parent_id))
(live_repositories + selected_snapshots).sort_by { |r| r.name.downcase }
end
def update_report_repository_references(repository)
ids = if repository.is_a?(Repository)
RepositorySnapshot.where(parent_id: repository.id).pluck(:id)

View file

@ -57,7 +57,7 @@
</div>
</div>
<!-- Assigned items -->
<% assigned_repositories = @my_module.readable_live_and_snapshot_repositories_list(current_user) %>
<% assigned_repositories = @my_module.live_and_snapshot_repositories_list %>
<div class="task-section">
<div class="task-section-header">
<a class="task-section-caret" role="button" data-toggle="collapse" href="#assigned-items-container" aria-expanded="true" aria-controls="assigned-items-container">