Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ PRIMO_API_URL=https://api-na.hosted.exlibrisgroup.com/primo/v1
PRIMO_SCOPE=cdi
PRIMO_TAB=all
PRIMO_VID=01MIT_INST:MIT
RESULTS_PER_PAGE=20
SYNDETICS_PRIMO_URL=https://syndetics.com/index.php?client=primo
TACOS_HOST=FAKE_TACOS_HOST
TACOS_URL=http://FAKE_TACOS_HOST/graphql
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def fetch_primo_data(offset: nil, per_page: nil)
def fetch_timdex_data(offset: nil, per_page: nil)
query = QueryBuilder.new(@enhanced_query).query
query['from'] = offset.to_s if offset
query['size'] = per_page.to_s if per_page
query['perPage'] = per_page || ENV.fetch('RESULTS_PER_PAGE', '20').to_i
query['fulltext'] = true if Feature.enabled?(:timdex_fulltext)

response = query_timdex(query)
Expand Down
37 changes: 37 additions & 0 deletions test/models/analyzer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -318,4 +318,41 @@ class AnalyzerTest < ActiveSupport::TestCase
assert_equal 100, pagination[:end] # 2 * 50
end
end

test 'analyzer correctly handles configurable results per page' do
eq = {
q: 'data',
page: 1
}

ClimateControl.modify RESULTS_PER_PAGE: '50' do
pagination = Analyzer.new(eq, 500, :timdex).pagination

assert_equal 50, pagination[:per_page]
assert_equal 1, pagination[:start]
assert_equal 50, pagination[:end]
assert_equal 2, pagination[:next]
refute pagination.key?(:prev)
end
end

test 'analyzer correctly handles configurable results per page for all tab' do
eq = {
q: 'data',
page: 1
}

ClimateControl.modify RESULTS_PER_PAGE: '50' do
pagination = Analyzer.new(eq, 500, :all, 300).pagination

# Combined hits: 300 + 500 = 800
# Page 1 with 50 per page: 1-50 of 800
assert_equal 50, pagination[:per_page]
assert_equal 800, pagination[:hits]
assert_equal 1, pagination[:start]
assert_equal 50, pagination[:end]
assert_equal 2, pagination[:next]
refute pagination.key?(:prev)
end
end
end
77 changes: 30 additions & 47 deletions test/vcr_cassettes/timdex_error.yml

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions test/vcr_cassettes/timdex_no_results.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.