Skip to content

Commit c83fe80

Browse files
Tim WrightTim Wright
authored andcommitted
tidy ups
1 parent b590351 commit c83fe80

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

app/params/supplejack_api/concerns/helpers_params.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ def cast_param(_name, value)
2424
def integer_param(param, value)
2525
@user = User.find_by_auth_token(params[:api_key])
2626

27-
if self.class.max_values[param] < value
28-
if @user.nil? || @user&.role == 'anonymous'
27+
if param == 'page' && (@user.nil? || @user&.role == 'anonymous') && 100 < value
2928
# rubocop:disable Layout/LineLength
3029
errors << "The #{param} parameter for anonymous users (without an API key) can not exceed #{self.class.max_values[param]}"
3130
# rubocop:enable Layout/LineLength
32-
else
33-
errors << "The #{param} parameter can not exceed #{self.class.max_values[param]}"
34-
end
31+
end
32+
33+
if self.class.max_values[param] < value
34+
errors << "The #{param} parameter can not exceed #{self.class.max_values[param]}"
3535
end
3636

3737
value = value.to_i

app/params/supplejack_api/mlt_params.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class MltParams < BaseParams
1616
class_attribute :max_values
1717

1818
self.max_values = {
19-
page: @user.nil? || @user&.role == 'anonymous' ? 100 : 50_000,
19+
page: 50_000,
2020
per_page: 100
2121
}
2222

@@ -37,7 +37,6 @@ def initialize(**kwargs)
3737
@record_type = @params[:record_type]
3838

3939
@debug = kwargs[:debug] == 'true'
40-
@user = User.find_by_auth_token(params[:api_key])
4140
end
4241

4342
def valid?

app/params/supplejack_api/search_params.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class SearchParams < BaseParams
2727
class_attribute :max_values
2828

2929
self.max_values = {
30-
page: @user.nil? || @user&.role == 'anonymous' ? 100 : 50_000,
30+
page: 50_000,
3131
per_page: 100,
3232
facets_per_page: 350,
3333
facets_page: 5000
@@ -55,7 +55,6 @@ def initialize(**kwargs)
5555

5656
@solr_query = @params[:solr_query]
5757
@debug = @params[:debug] == 'true'
58-
@user = User.find_by_auth_token(params[:api_key])
5958
end
6059

6160
private

0 commit comments

Comments
 (0)