summaryrefslogtreecommitdiff
path: root/app/models/project.rb
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-09-15 13:19:53 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2016-09-15 13:19:53 +0200
commit50076ab974348e74514bb4f19169351f08e11636 (patch)
treef3ba725e2170e58513995fe941fef30ac13afb45 /app/models/project.rb
parent11f87700e8bceeec96440809682406ae24334ed8 (diff)
parent4768521a6e9d6d8b9a57398ebb5d03aed5b5ac77 (diff)
downloadgitlab-ce-50076ab974348e74514bb4f19169351f08e11636.tar.gz
Merge remote-tracking branch 'origin/master' into per-build-token
# Conflicts: # db/schema.rb
Diffstat (limited to 'app/models/project.rb')
-rw-r--r--app/models/project.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index d7cdf8775b3..16ca2b688c8 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -58,7 +58,7 @@ class Project < ActiveRecord::Base
# Relations
belongs_to :creator, foreign_key: 'creator_id', class_name: 'User'
- belongs_to :group, -> { where(type: Group) }, foreign_key: 'namespace_id'
+ belongs_to :group, -> { where(type: 'Group') }, foreign_key: 'namespace_id'
belongs_to :namespace
has_one :last_event, -> {order 'events.created_at DESC'}, class_name: 'Event', foreign_key: 'project_id'
@@ -1282,8 +1282,24 @@ class Project < ActiveRecord::Base
end
end
+ def pushes_since_gc
+ Gitlab::Redis.with { |redis| redis.get(pushes_since_gc_redis_key).to_i }
+ end
+
+ def increment_pushes_since_gc
+ Gitlab::Redis.with { |redis| redis.incr(pushes_since_gc_redis_key) }
+ end
+
+ def reset_pushes_since_gc
+ Gitlab::Redis.with { |redis| redis.del(pushes_since_gc_redis_key) }
+ end
+
private
+ def pushes_since_gc_redis_key
+ "projects/#{id}/pushes_since_gc"
+ end
+
# Prevents the creation of project_feature record for every project
def setup_project_feature
build_project_feature unless project_feature