Skip to content

Commit

Permalink
Make dashboard pagination default "per" param configurable (#597)
Browse files Browse the repository at this point in the history
* Make dashboard pagination default "per" param configurable
  • Loading branch information
alopatin authored and andrehjr committed Nov 5, 2019
1 parent 812ec83 commit 4cfefe6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions lib/split/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Configuration
attr_accessor :beta_probability_simulations
attr_accessor :winning_alternative_recalculation_interval
attr_accessor :redis
attr_accessor :dashboard_pagination_default_per_page

attr_reader :experiments

Expand Down Expand Up @@ -226,6 +227,7 @@ def initialize
@beta_probability_simulations = 10000
@winning_alternative_recalculation_interval = 60 * 60 * 24 # 1 day
@redis = ENV.fetch(ENV.fetch('REDIS_PROVIDER', 'REDIS_URL'), 'redis://localhost:6379')
@dashboard_pagination_default_per_page = 10
end

def redis_url=(value)
Expand Down
5 changes: 2 additions & 3 deletions lib/split/dashboard/pagination_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@

module Split
module DashboardPaginationHelpers
DEFAULT_PER = 10

def pagination_per
@pagination_per ||= (params[:per] || DEFAULT_PER).to_i
default_per_page = Split.configuration.dashboard_pagination_default_per_page
@pagination_per ||= (params[:per] || default_per_page).to_i
end

def page_number
Expand Down
4 changes: 3 additions & 1 deletion spec/dashboard/pagination_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
context 'when params empty' do
let(:params) { Hash[] }

it 'returns 10' do
it 'returns the default (10)' do
default_per_page = Split.configuration.dashboard_pagination_default_per_page
expect(pagination_per).to eql default_per_page
expect(pagination_per).to eql 10
end
end
Expand Down

0 comments on commit 4cfefe6

Please sign in to comment.