From 0ca08849370807656546932f6632af431fef6a5e Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Tue, 15 May 2018 17:48:48 +0200 Subject: [PATCH] Fix pagination in global search inside repositories [SCI-2411] --- app/controllers/search_controller.rb | 11 ++++++++++- app/views/search/index.html.erb | 16 +++++++++++++--- app/views/search/results/_repositories.html.erb | 1 + 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 2e346334a..ef6de18c1 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -154,6 +154,15 @@ class SearchController < ApplicationController count_total end + def current_repository_search_count + @repository_search_count.each_value do |counter| + res = counter[:repositories].values.detect do |rep| + rep[:id] == @repository.id + end + return res[:count] + end + end + def count_search_results @project_search_count = fetch_cached_count Project @experiment_search_count = fetch_cached_count Experiment @@ -265,7 +274,7 @@ class SearchController < ApplicationController whole_word: @search_whole_word, whole_phrase: @search_whole_phrase) end - @search_count = @repository_search_count_total + @search_count = current_repository_search_count end def search_assets diff --git a/app/views/search/index.html.erb b/app/views/search/index.html.erb index 5c4c1cced..9d7a21ef1 100644 --- a/app/views/search/index.html.erb +++ b/app/views/search/index.html.erb @@ -298,23 +298,33 @@ <% end %> <% if @search_pages > 1 %> + <% params = { q: @search_query, + category: @search_category, + utf8: '✓', + search_id: @search_id } %> + <% if @search_category == :repositories %> + <% params[:repository] = @repository.id %> + <% end %>