summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2017-06-19 18:24:14 +0100
committerTiago Botelho <tiagonbotelho@hotmail.com>2017-06-28 17:51:05 +0100
commit1fbb7f977777de7c8808429693359c7a98ffdfcc (patch)
treebb872e346a9fb3b6c6d9001196ee931dba632387 /app/models
parent34f57b462bc14ad194cf890a4585d403bdbde55c (diff)
downloadgitlab-ce-1fbb7f977777de7c8808429693359c7a98ffdfcc.tar.gz
Removes redundant pending delete checks30708-stop-using-deleted-at-to-filter-namespaces
Diffstat (limited to 'app/models')
-rw-r--r--app/models/namespace.rb2
-rw-r--r--app/models/project.rb5
2 files changed, 4 insertions, 3 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/project.rb b/app/models/project.rb
index 40a8e7f07c6..65f81727071 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -222,7 +222,7 @@ class Project < ActiveRecord::Base
has_many :uploads, as: :model, dependent: :destroy
# Scopes
- scope :with_deleted, -> { where(pending_delete: true) }
+ scope :pending_delete, -> { where(pending_delete: true) }
scope :without_deleted, -> { where(pending_delete: false) }
scope :sorted_by_activity, -> { reorder(last_activity_at: :desc) }
@@ -376,7 +376,6 @@ class Project < ActiveRecord::Base
.or(ptable[:description].matches(pattern))
)
-
namespaces = unscoped.select(:id)
.joins(:namespace)
.where(ntable[:name].matches(pattern))
@@ -1456,7 +1455,7 @@ class Project < ActiveRecord::Base
def pending_delete_twin
return false unless path
- Project.with_deleted.find_by_full_path(path_with_namespace)
+ Project.pending_delete.find_by_full_path(path_with_namespace)
end
##