Allow to configure limit for requests creation
This commit is contained in:
parent
b898d863c0
commit
a35d78afd8
|
@ -369,6 +369,3 @@ DEPENDENCIES
|
||||||
travis-yaml!
|
travis-yaml!
|
||||||
unicorn
|
unicorn
|
||||||
yard-sinatra!
|
yard-sinatra!
|
||||||
|
|
||||||
BUNDLED WITH
|
|
||||||
1.10.5
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module Travis::API::V3
|
module Travis::API::V3
|
||||||
class Services::Requests::Create < Service
|
class Services::Requests::Create < Service
|
||||||
TIME_FRAME = 1.hour
|
TIME_FRAME = 1.hour
|
||||||
LIMIT = 50
|
LIMIT = 10
|
||||||
private_constant :TIME_FRAME, :LIMIT
|
private_constant :TIME_FRAME, :LIMIT
|
||||||
|
|
||||||
result_type :request
|
result_type :request
|
||||||
|
@ -22,10 +22,14 @@ module Travis::API::V3
|
||||||
accepted(remaining_requests: remaining, repository: repository, request: payload)
|
accepted(remaining_requests: remaining, repository: repository, request: payload)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def limit
|
||||||
|
Travis.config.requests_create_api_limit || LIMIT
|
||||||
|
end
|
||||||
|
|
||||||
def remaining_requests(repository)
|
def remaining_requests(repository)
|
||||||
return LIMIT if access_control.full_access?
|
return limit if access_control.full_access?
|
||||||
count = query(:requests).count(repository, TIME_FRAME)
|
count = query(:requests).count(repository, TIME_FRAME)
|
||||||
count > LIMIT ? 0 : LIMIT - count
|
count > limit ? 0 : limit - count
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user