mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-11 01:44:34 +08:00
Improve loading speed of protocol template [SCI-10171] (#7077)
This commit is contained in:
parent
bf6e990435
commit
230b580ba2
1 changed files with 16 additions and 1 deletions
|
@ -146,7 +146,22 @@ class ProtocolsDatatable < CustomDatatable
|
|||
end
|
||||
|
||||
def get_raw_records_base
|
||||
records = Protocol.latest_available_versions(@team)
|
||||
team_protocols = Protocol.where(team: @team)
|
||||
original_without_versions = team_protocols
|
||||
.left_outer_joins(:published_versions)
|
||||
.in_repository_published_original
|
||||
.where(published_versions: { id: nil })
|
||||
.select(:id)
|
||||
published_versions = team_protocols
|
||||
.in_repository_published_version
|
||||
.order(:parent_id, version_number: :desc)
|
||||
.select('DISTINCT ON (parent_id) id')
|
||||
new_drafts = team_protocols
|
||||
.where(protocol_type: Protocol.protocol_types[:in_repository_draft], parent_id: nil)
|
||||
.select(:id)
|
||||
|
||||
records = Protocol.where('protocols.id IN (?) OR protocols.id IN (?) OR protocols.id IN (?)',
|
||||
original_without_versions, published_versions, new_drafts)
|
||||
|
||||
records = @type == :archived ? records.archived : records.active
|
||||
|
||||
|
|
Loading…
Reference in a new issue