mirror of
https://github.com/redmine/redmine.git
synced 2025-11-10 23:36:01 +01:00
Rewrites search engine to properly paginate results (#18631).
Instead of counting and retrieving results based on their timestamps, we now load all result ids then load the appropriate results by their ids. This also brings a 2x performance improvement as we search tokens in one of the 2 queries only. git-svn-id: http://svn.redmine.org/redmine/trunk@13739 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -75,8 +75,8 @@ class SearchControllerTest < ActionController::TestCase
|
||||
assert_select 'dt.issue a', :text => /Add ingredients categories/
|
||||
assert_select 'dd', :text => /should be classified by categories/
|
||||
|
||||
assert assigns(:results_by_type).is_a?(Hash)
|
||||
assert_equal 5, assigns(:results_by_type)['changesets']
|
||||
assert assigns(:result_count_by_type).is_a?(Hash)
|
||||
assert_equal 5, assigns(:result_count_by_type)['changesets']
|
||||
assert_select 'a', :text => 'Changesets (5)'
|
||||
end
|
||||
|
||||
@@ -222,20 +222,24 @@ class SearchControllerTest < ActionController::TestCase
|
||||
assert_equal 1, results.size
|
||||
end
|
||||
|
||||
def test_search_with_offset
|
||||
get :index, :q => 'coo', :offset => '20080806073000'
|
||||
assert_response :success
|
||||
results = assigns(:results)
|
||||
assert results.any?
|
||||
assert results.map(&:event_datetime).max < '20080806T073000'.to_time
|
||||
end
|
||||
def test_search_with_pagination
|
||||
issue = (0..24).map {Issue.generate! :subject => 'search_with_limited_results'}.reverse
|
||||
|
||||
def test_search_previous_with_offset
|
||||
get :index, :q => 'coo', :offset => '20080806073000', :previous => '1'
|
||||
get :index, :q => 'search_with_limited_results'
|
||||
assert_response :success
|
||||
results = assigns(:results)
|
||||
assert results.any?
|
||||
assert results.map(&:event_datetime).min >= '20080806T073000'.to_time
|
||||
assert_equal issue[0..9], assigns(:results)
|
||||
|
||||
get :index, :q => 'search_with_limited_results', :page => 2
|
||||
assert_response :success
|
||||
assert_equal issue[10..19], assigns(:results)
|
||||
|
||||
get :index, :q => 'search_with_limited_results', :page => 3
|
||||
assert_response :success
|
||||
assert_equal issue[20..24], assigns(:results)
|
||||
|
||||
get :index, :q => 'search_with_limited_results', :page => 4
|
||||
assert_response :success
|
||||
assert_equal [], assigns(:results)
|
||||
end
|
||||
|
||||
def test_search_with_invalid_project_id
|
||||
|
||||
Reference in New Issue
Block a user