Code style fixes [SCI-1356]

This commit is contained in:
Oleksii Kriuchykhin 2017-06-27 13:23:51 +02:00
parent fc72453a5b
commit 4060ba2ac3
3 changed files with 29 additions and 29 deletions

View file

@ -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

View file

@ -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>

View file

@ -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