diff options
author | Paco Guzman <pacoguzmanp@gmail.com> | 2016-09-21 17:33:57 +0200 |
---|---|---|
committer | Paco Guzman <pacoguzmanp@gmail.com> | 2016-10-04 14:37:59 +0200 |
commit | 528e26bd49bcf389e1e104b5e34f86c479b4faee (patch) | |
tree | 1908cc09bdb47ad7111644f34ea9c10bfabddbf0 | |
parent | 77de91e1b02e48cd15a0bced8f5b92f272b82e3a (diff) | |
download | gitlab-ce-avoid-query-project-on-initialize-just-when-needed.tar.gz |
This can be work ?¿avoid-query-project-on-initialize-just-when-needed
-rw-r--r-- | app/models/project.rb | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 507228606df..ef9b2e2d464 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -27,7 +27,6 @@ class Project < ActiveRecord::Base after_create :ensure_dir_exist after_save :ensure_dir_exist, if: :namespace_id_changed? - after_initialize :setup_project_feature # set last_activity_at to the same as created_at after_create :set_last_activity_at @@ -1306,17 +1305,17 @@ class Project < ActiveRecord::Base end end + # Build the association if not exists already when access to it + def project_feature + super || (build_project_feature and super) + 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 - end - def default_branch_protected? current_application_settings.default_branch_protection == Gitlab::Access::PROTECTION_FULL || current_application_settings.default_branch_protection == Gitlab::Access::PROTECTION_DEV_CAN_MERGE |