diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-03-06 14:29:11 +0100 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-03-06 14:42:04 +0100 |
commit | 0c71a4c41465cd620e163e081f31567ce59de766 (patch) | |
tree | 5c7a14a7a405a06f571391911eb124e4e958c89a /lib/api/helpers.rb | |
parent | 1ba0a907f77f9b3693485e3c7080c8de6fdf1b92 (diff) | |
download | gitlab-ci-0c71a4c41465cd620e163e081f31567ce59de766.tar.gz |
Added runner last contact
Diffstat (limited to 'lib/api/helpers.rb')
-rw-r--r-- | lib/api/helpers.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index fc19d76..58297a8 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -2,6 +2,7 @@ module API module Helpers PRIVATE_TOKEN_PARAM = :private_token PRIVATE_TOKEN_HEADER = "HTTP_PRIVATE_TOKEN" + UPDATE_RUNNER_EVERY = 60 def current_user @current_user ||= begin @@ -33,6 +34,12 @@ module API forbidden! unless project.valid_token?(params[:project_token]) end + def update_runner_last_contact + if current_runner.contacted_at.nil? || Time.now - current_runner.contacted_at >= UPDATE_RUNNER_EVERY + current_runner.update_attributes(contacted_at: Time.now) + end + end + # Checks the occurrences of required attributes, each attribute must be present in the params hash # or a Bad Request error is invoked. # |