mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-25 01:03:18 +08:00
commit
88462de1d5
3 changed files with 21 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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">
|
||||
|
|
Loading…
Reference in a new issue