summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-06-29 01:11:45 +0000
committerDouwe Maan <douwe@gitlab.com>2017-06-29 01:11:45 +0000
commitc89f7c71f69e575bb2e45746917decbbf9118203 (patch)
tree306f192360a6cde07bdc6795beeaa5f1f7e8c171 /app/models
parentb07c00032b038f40796a28e34b6dd4c622bad012 (diff)
parent1fbb7f977777de7c8808429693359c7a98ffdfcc (diff)
downloadgitlab-ce-c89f7c71f69e575bb2e45746917decbbf9118203.tar.gz
Merge branch '30708-stop-using-deleted-at-to-filter-namespaces' into 'master'
refactors Project#search namespace join Closes #30708 See merge request !12091
Diffstat (limited to 'app/models')
-rw-r--r--app/models/namespace.rb2
-rw-r--r--app/models/notification_setting.rb2
-rw-r--r--app/models/project.rb7
3 files changed, 6 insertions, 5 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index 583d4fb5244..efbed5a2ef5 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -47,6 +47,8 @@ class Namespace < ActiveRecord::Base
before_destroy(prepend: true) { prepare_for_destroy }
after_destroy :rm_dir
+ default_scope { with_deleted }
+
scope :for_user, -> { where('type IS NULL') }
scope :with_statistics, -> do
diff --git a/app/models/notification_setting.rb b/app/models/notification_setting.rb
index b0df7aeb323..81844b1e2ca 100644
--- a/app/models/notification_setting.rb
+++ b/app/models/notification_setting.rb
@@ -19,7 +19,7 @@ class NotificationSetting < ActiveRecord::Base
# pending delete).
#
scope :for_projects, -> do
- includes(:project).references(:projects).where(source_type: 'Project').where.not(projects: { id: nil })
+ includes(:project).references(:projects).where(source_type: 'Project').where.not(projects: { id: nil, pending_delete: true })
end
EMAIL_EVENTS = [
diff --git a/app/models/project.rb b/app/models/project.rb
index a5511c700e7..2c1c2278e2d 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -222,9 +222,8 @@ class Project < ActiveRecord::Base
has_many :uploads, as: :model, dependent: :destroy
# Scopes
- default_scope { where(pending_delete: false) }
-
- scope :with_deleted, -> { unscope(where: :pending_delete) }
+ scope :pending_delete, -> { where(pending_delete: true) }
+ scope :without_deleted, -> { where(pending_delete: false) }
scope :sorted_by_activity, -> { reorder(last_activity_at: :desc) }
scope :sorted_by_stars, -> { reorder('projects.star_count DESC') }
@@ -1460,7 +1459,7 @@ class Project < ActiveRecord::Base
def pending_delete_twin
return false unless path
- Project.unscoped.where(pending_delete: true).find_by_full_path(path_with_namespace)
+ Project.pending_delete.find_by_full_path(path_with_namespace)
end
##