Invalidate cache on build change

This commit is contained in:
Josh Frye 2016-05-31 16:01:16 -04:00
parent 2d05de7af8
commit 4d9622e7d3
2 changed files with 6 additions and 1 deletions

View file

@ -313,6 +313,7 @@ module Ci
build_data = Gitlab::BuildDataBuilder.build(self)
project.execute_hooks(build_data.dup, :build_hooks)
project.execute_services(build_data.dup, :build_hooks)
project.expire_running_or_pending_build_count
end
def artifacts?

View file

@ -1013,8 +1013,12 @@ class Project < ActiveRecord::Base
end
def running_or_pending_build_count
Rails.cache.fetch(['projects', id, 'running_or_pending_build_count'], expires_in: 60) do
Rails.cache.fetch(['projects', id, 'running_or_pending_build_count']) do
builds.running_or_pending.count(:all)
end
end
def expire_running_or_pending_build_count
Rails.cache.delete(['projects', id, 'running_or_pending_build_count'])
end
end