mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-10 17:36:33 +08:00
Code style fixes [SCI-1356]
This commit is contained in:
parent
fc72453a5b
commit
4060ba2ac3
3 changed files with 29 additions and 29 deletions
|
@ -110,7 +110,7 @@ class SearchController < ApplicationController
|
|||
end
|
||||
|
||||
def count_by_repository
|
||||
@repository_search_count_total = 0
|
||||
count_total = 0
|
||||
search_results = Repository.search(current_user,
|
||||
true,
|
||||
@search_query,
|
||||
|
@ -119,7 +119,7 @@ class SearchController < ApplicationController
|
|||
match_case: @search_case,
|
||||
whole_word: @search_whole_word,
|
||||
whole_phrase: @search_whole_phrase)
|
||||
matches_count = {}
|
||||
@repository_search_count = {}
|
||||
current_user.teams.includes(:repositories).each do |team|
|
||||
team_results = {}
|
||||
team_results[:count] = 0
|
||||
|
@ -130,16 +130,16 @@ class SearchController < ApplicationController
|
|||
repository_results[:count] = 0
|
||||
search_results.each do |result|
|
||||
if repository.id == result.id
|
||||
@repository_search_count_total += result.counter
|
||||
count_total += result.counter
|
||||
repository_results[:count] += result.counter
|
||||
end
|
||||
end
|
||||
team_results[:repositories][repository.name] = repository_results
|
||||
team_results[:count] += repository_results[:count]
|
||||
end
|
||||
matches_count[team.name] = team_results
|
||||
@repository_search_count[team.name] = team_results
|
||||
end
|
||||
matches_count
|
||||
count_total
|
||||
end
|
||||
|
||||
def count_search_results
|
||||
|
@ -154,7 +154,7 @@ class SearchController < ApplicationController
|
|||
@step_search_count = count_by_name Step
|
||||
@checklist_search_count = count_by_name Checklist
|
||||
@sample_search_count = count_by_name Sample
|
||||
@repository_search_count = count_by_repository
|
||||
@repository_search_count_total = count_by_repository
|
||||
@asset_search_count = count_by_name Asset
|
||||
@table_search_count = count_by_name Table
|
||||
@comment_search_count = count_by_name Comment
|
||||
|
|
|
@ -188,28 +188,6 @@
|
|||
</a>
|
||||
</li>
|
||||
|
||||
<% @repository_search_count.each do |team, results| %>
|
||||
<li class="repositories-team <%= 'active' if results[:count] > 0 %>">
|
||||
<span class="fa fa-cubes"></span>
|
||||
<%= t('Repositories_team', team: team) %>
|
||||
</li>
|
||||
<% results[:repositories].each do |repository, values| %>
|
||||
<li role="presentation"
|
||||
class="
|
||||
<%= "active" if @search_category.present? and @search_category == :repositories and @repository.id == values[:id] %>
|
||||
<%= "disabled" if values[:count] == 0 %> repository-search"
|
||||
>
|
||||
<a href="?<%= {category: 'repositories',
|
||||
repository: values[:id], q: @search_query,
|
||||
whole_word: @search_whole_word, whole_phrase: @search_whole_phrase,
|
||||
match_case: @search_case, utf8: '✓'}.to_query %>">
|
||||
<span class="badge pull-right"><%= values[:count] %></span>
|
||||
<%= repository %>
|
||||
</a>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<li role="presentation"
|
||||
class="
|
||||
<%= "active" if @search_category.present? and @search_category == :assets %>
|
||||
|
@ -249,6 +227,28 @@
|
|||
<%= t'Comments' %>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<% @repository_search_count.each do |team, results| %>
|
||||
<li class="repositories-team <%= 'active' if results[:count] > 0 %>">
|
||||
<span class="fa fa-cubes"></span>
|
||||
<%= t('Repositories_team', team: team) %>
|
||||
</li>
|
||||
<% results[:repositories].each do |repository, values| %>
|
||||
<li role="presentation"
|
||||
class="
|
||||
<%= "active" if @search_category == :repositories && @repository.id == values[:id] %>
|
||||
<%= "disabled" if values[:count] == 0 %> repository-search"
|
||||
>
|
||||
<a href="?<%= {category: 'repositories',
|
||||
repository: values[:id], q: @search_query,
|
||||
whole_word: @search_whole_word, whole_phrase: @search_whole_phrase,
|
||||
match_case: @search_case, utf8: '✓'}.to_query %>">
|
||||
<span class="badge pull-right"><%= values[:count] %></span>
|
||||
<%= repository %>
|
||||
</a>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ class AddSearchIndexesToRepositories < ActiveRecord::Migration
|
|||
|
||||
def down
|
||||
if db_adapter_is? 'PostgreSQL'
|
||||
remove_index :repositorepository_rows, :name
|
||||
remove_index :repository_rows, :name
|
||||
remove_index :repository_text_values, :data
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue