diff options
author | Valery Sizov <valery@gitlab.com> | 2015-03-06 15:43:40 +0000 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2015-03-06 15:43:40 +0000 |
commit | b04101fc3a618949b06b746afecb6714119365ab (patch) | |
tree | 5c7a14a7a405a06f571391911eb124e4e958c89a /lib/api/helpers.rb | |
parent | 1ba0a907f77f9b3693485e3c7080c8de6fdf1b92 (diff) | |
parent | 0c71a4c41465cd620e163e081f31567ce59de766 (diff) | |
download | gitlab-ci-b04101fc3a618949b06b746afecb6714119365ab.tar.gz |
Merge branch 'last_contact' into 'master'
Last contact
Added information about runner's last contact time. The information is updated at most once a minute to reduce database workload.
See merge request !44
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. # |