Commit 1fbb7f97 authored by Tiago Botelho's avatar Tiago Botelho

Removes redundant pending delete checks

parent 34f57b46
...@@ -78,7 +78,6 @@ class TodosFinder ...@@ -78,7 +78,6 @@ class TodosFinder
end end
def project def project
return nil if @project&.pending_delete?
return @project if defined?(@project) return @project if defined?(@project)
if project? if project?
...@@ -98,7 +97,7 @@ class TodosFinder ...@@ -98,7 +97,7 @@ class TodosFinder
def projects(items) def projects(items)
item_project_ids = items.reorder(nil).select(:project_id) item_project_ids = items.reorder(nil).select(:project_id)
ProjectsFinder.new(current_user: current_user, project_ids_relation: item_project_ids).execute.without_deleted ProjectsFinder.new(current_user: current_user, project_ids_relation: item_project_ids).execute
end end
def type? def type?
......
...@@ -97,8 +97,8 @@ module SearchHelper ...@@ -97,8 +97,8 @@ module SearchHelper
# Autocomplete results for the current user's projects # Autocomplete results for the current user's projects
def projects_autocomplete(term, limit = 5) def projects_autocomplete(term, limit = 5)
current_user.authorized_projects.search_by_title(term). current_user.authorized_projects.search_by_title(term)
sorted_by_stars.non_archived.limit(limit).map do |p| .sorted_by_stars.non_archived.limit(limit).map do |p|
{ {
category: "Projects", category: "Projects",
id: p.id, id: p.id,
......
...@@ -47,6 +47,8 @@ class Namespace < ActiveRecord::Base ...@@ -47,6 +47,8 @@ class Namespace < ActiveRecord::Base
before_destroy(prepend: true) { prepare_for_destroy } before_destroy(prepend: true) { prepare_for_destroy }
after_destroy :rm_dir after_destroy :rm_dir
default_scope { with_deleted }
scope :for_user, -> { where('type IS NULL') } scope :for_user, -> { where('type IS NULL') }
scope :with_statistics, -> do scope :with_statistics, -> do
......
...@@ -222,7 +222,7 @@ class Project < ActiveRecord::Base ...@@ -222,7 +222,7 @@ class Project < ActiveRecord::Base
has_many :uploads, as: :model, dependent: :destroy has_many :uploads, as: :model, dependent: :destroy
# Scopes # Scopes
scope :with_deleted, -> { where(pending_delete: true) } scope :pending_delete, -> { where(pending_delete: true) }
scope :without_deleted, -> { where(pending_delete: false) } scope :without_deleted, -> { where(pending_delete: false) }
scope :sorted_by_activity, -> { reorder(last_activity_at: :desc) } scope :sorted_by_activity, -> { reorder(last_activity_at: :desc) }
...@@ -376,7 +376,6 @@ class Project < ActiveRecord::Base ...@@ -376,7 +376,6 @@ class Project < ActiveRecord::Base
.or(ptable[:description].matches(pattern)) .or(ptable[:description].matches(pattern))
) )
namespaces = unscoped.select(:id) namespaces = unscoped.select(:id)
.joins(:namespace) .joins(:namespace)
.where(ntable[:name].matches(pattern)) .where(ntable[:name].matches(pattern))
...@@ -1456,7 +1455,7 @@ class Project < ActiveRecord::Base ...@@ -1456,7 +1455,7 @@ class Project < ActiveRecord::Base
def pending_delete_twin def pending_delete_twin
return false unless path 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 end
## ##
......
...@@ -54,9 +54,9 @@ module Ci ...@@ -54,9 +54,9 @@ module Ci
def builds_for_shared_runner def builds_for_shared_runner
new_builds. new_builds.
# don't run projects which have not enabled shared runners and builds # don't run projects which have not enabled shared runners and builds
joins(:project).where(projects: { shared_runners_enabled: true, pending_delete: false }). joins(:project).where(projects: { shared_runners_enabled: true, pending_delete: false })
joins('LEFT JOIN project_features ON ci_builds.project_id = project_features.project_id'). .joins('LEFT JOIN project_features ON ci_builds.project_id = project_features.project_id')
where('project_features.builds_access_level IS NULL or project_features.builds_access_level > 0'). .where('project_features.builds_access_level IS NULL or project_features.builds_access_level > 0').
# Implement fair scheduling # Implement fair scheduling
# this returns builds that are ordered by number of running builds # this returns builds that are ordered by number of running builds
......
...@@ -317,23 +317,6 @@ feature 'Dashboard Todos' do ...@@ -317,23 +317,6 @@ feature 'Dashboard Todos' do
end end
end end
context 'User has a Todo in a project pending deletion' do
before do
deleted_project = create(:project, :public, pending_delete: true)
create(:todo, :mentioned, user: user, project: deleted_project, target: issue, author: author)
create(:todo, :mentioned, user: user, project: deleted_project, target: issue, author: author, state: :done)
sign_in(user)
visit dashboard_todos_path
end
it 'shows "All done" message' do
within('.todos-count') { expect(page).to have_content '0' }
expect(page).to have_content 'To do 0'
expect(page).to have_content 'Done 0'
expect(page).to have_selector('.todos-all-done', count: 1)
end
end
context 'User has a Build Failed todo' do context 'User has a Build Failed todo' do
let!(:todo) { create(:todo, :build_failed, user: user, project: project, author: author) } let!(:todo) { create(:todo, :build_failed, user: user, project: project, author: author) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment