Merge pull request #1309 from biosistemika/release-1.14.5

Merge release-1.14.5 into master
This commit is contained in:
Luka Murn 2018-09-20 08:53:51 +02:00 committed by GitHub
commit 5d6881bae1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 22 deletions

View file

@ -1 +1 @@
1.14.4
1.14.5

View file

@ -173,7 +173,6 @@ class SearchController < ApplicationController
@protocol_search_count = fetch_cached_count Protocol
@step_search_count = fetch_cached_count Step
@checklist_search_count = fetch_cached_count Checklist
@sample_search_count = fetch_cached_count Sample
@repository_search_count_total = count_by_repository
@asset_search_count = fetch_cached_count Asset
@table_search_count = fetch_cached_count Table
@ -188,7 +187,6 @@ class SearchController < ApplicationController
@search_results_count += @protocol_search_count
@search_results_count += @step_search_count
@search_results_count += @checklist_search_count
@search_results_count += @sample_search_count
@search_results_count += @repository_search_count_total
@search_results_count += @asset_search_count
@search_results_count += @table_search_count

View file

@ -98,23 +98,31 @@ class Asset < ApplicationRecord
options = {}
)
project_ids =
Project
.search(user, include_archived, nil, Constants::SEARCH_NO_LIMIT)
.pluck(:id)
team_ids = user.teams.pluck(:id)
teams = user.teams.select(:id)
new_query =
Asset
.distinct
.left_outer_joins(:asset_text_datum)
.left_outer_joins(
step: { protocol: { my_module: { experiment: :project } } }
)
.left_outer_joins(result: { my_module: { experiment: :project } })
.left_outer_joins(repository_cell: { repository_column: :repository })
.where('projects.id IN (?) OR repositories.team_id IN (?)',
project_ids, team_ids)
assets_in_steps = Asset.joins(:step).where(
'steps.id IN (?)',
Step.search(user, include_archived, nil, Constants::SEARCH_NO_LIMIT)
.select(:id)
).pluck(:id)
assets_in_results = Asset.joins(:result).where(
'results.id IN (?)',
Result.search(user, include_archived, nil, Constants::SEARCH_NO_LIMIT)
.select(:id)
).pluck(:id)
assets_in_inventories = Asset.joins(
repository_cell: { repository_column: :repository }
).where('repositories.team_id IN (?)', teams).pluck(:id)
assets =
Asset.distinct
.where('assets.id IN (?) OR assets.id IN (?) OR assets.id IN (?)',
assets_in_steps, assets_in_results, assets_in_inventories)
new_query = Asset.left_outer_joins(:asset_text_datum)
.from(assets, 'assets')
a_query = s_query = ''

View file

@ -34,16 +34,19 @@ class Repository < ApplicationRecord
repository = nil,
options = {}
)
repositories = repository ? repository : Repository.where(team: user.teams)
repositories = repository || Repository.where(team: user.teams)
includes_json = { repository_cells: Extends::REPOSITORY_SEARCH_INCLUDES }
searchable_attributes = ['repository_rows.name', 'users.full_name'] +
Extends::REPOSITORY_EXTRA_SEARCH_ATTR
all_rows = RepositoryRow.where(repository: repositories)
new_query = RepositoryRow
.distinct
.from(all_rows, 'repository_rows')
.left_outer_joins(:created_by)
.left_outer_joins(includes_json)
.where(repository: repositories)
.where_attributes_like(searchable_attributes, query, options)
# Show all results if needed
@ -56,7 +59,6 @@ class Repository < ApplicationRecord
.group('repositories.id')
else
new_query
.distinct
.limit(Constants::SEARCH_LIMIT)
.offset((page - 1) * Constants::SEARCH_LIMIT)
end