From a35d78afd82d656be984c1c9c081912c166bc9f4 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 8 Jul 2015 13:55:40 +0200 Subject: [PATCH] Allow to configure limit for requests creation --- Gemfile.lock | 3 --- lib/travis/api/v3/services/requests/create.rb | 10 +++++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 41aeb82a..831de498 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -369,6 +369,3 @@ DEPENDENCIES travis-yaml! unicorn yard-sinatra! - -BUNDLED WITH - 1.10.5 diff --git a/lib/travis/api/v3/services/requests/create.rb b/lib/travis/api/v3/services/requests/create.rb index 5137ff60..63de899d 100644 --- a/lib/travis/api/v3/services/requests/create.rb +++ b/lib/travis/api/v3/services/requests/create.rb @@ -1,7 +1,7 @@ module Travis::API::V3 class Services::Requests::Create < Service TIME_FRAME = 1.hour - LIMIT = 50 + LIMIT = 10 private_constant :TIME_FRAME, :LIMIT result_type :request @@ -22,10 +22,14 @@ module Travis::API::V3 accepted(remaining_requests: remaining, repository: repository, request: payload) end + def limit + Travis.config.requests_create_api_limit || LIMIT + end + 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 > LIMIT ? 0 : LIMIT - count + count > limit ? 0 : limit - count end end end