diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-04-05 16:09:34 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-04-05 16:09:34 +0300 |
commit | b2a7faa5a9223811884676bb1004f97fb8a18a54 (patch) | |
tree | d48eb8943124ccde080a17c3e157e4249abde5f4 /app/models/project.rb | |
parent | 63a1a57024e54ff6aee1f099ca7b431a7bb0e669 (diff) | |
parent | 0f66a1b4a0f50b0db1adb279ad1c8c1af4a76c8c (diff) |
Merge branch 'use-chronic-duration-attribute-for-project-build-timeout' into 'master'
Use chronic duration attribute for project build timeout
See merge request gitlab-org/gitlab-ce!17386
Diffstat (limited to 'app/models/project.rb')
-rw-r--r-- | app/models/project.rb | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 32289106f28..ea9df9b10ef 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -21,6 +21,7 @@ class Project < ActiveRecord::Base include Gitlab::SQL::Pattern include DeploymentPlatform include ::Gitlab::Utils::StrongMemoize + include ChronicDurationAttribute extend Gitlab::ConfigHelper @@ -325,6 +326,12 @@ class Project < ActiveRecord::Base enum auto_cancel_pending_pipelines: { disabled: 0, enabled: 1 } + chronic_duration_attr :build_timeout_human_readable, :build_timeout, default: 3600 + + validates :build_timeout, allow_nil: true, + numericality: { greater_than_or_equal_to: 600, + message: 'needs to be at least 10 minutes' } + # Returns a collection of projects that is either public or visible to the # logged in user. def self.public_or_visible_to_user(user = nil) @@ -1309,14 +1316,6 @@ class Project < ActiveRecord::Base self.runners_token && ActiveSupport::SecurityUtils.variable_size_secure_compare(token, self.runners_token) end - def build_timeout_in_minutes - build_timeout / 60 - end - - def build_timeout_in_minutes=(value) - self.build_timeout = value.to_i * 60 - end - def open_issues_count Projects::OpenIssuesCountService.new(self).count end |