BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
c89f7c71
Commit
c89f7c71
authored
Jun 29, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '30708-stop-using-deleted-at-to-filter-namespaces' into 'master'
refactors Project#search namespace join Closes #30708 See merge request !12091
parents
b07c0003
1fbb7f97
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
23 additions
and
40 deletions
+23
-40
projects_controller.rb
app/controllers/projects_controller.rb
+1
-1
todos_finder.rb
app/finders/todos_finder.rb
+2
-0
namespace.rb
app/models/namespace.rb
+2
-0
notification_setting.rb
app/models/notification_setting.rb
+1
-1
project.rb
app/models/project.rb
+3
-4
register_job_service.rb
app/services/ci/register_job_service.rb
+2
-2
destroy_service.rb
app/services/groups/destroy_service.rb
+1
-1
destroy_service.rb
app/services/users/destroy_service.rb
+1
-1
_list.html.haml
app/views/shared/projects/_list.html.haml
+1
-1
stuck_ci_jobs_worker.rb
app/workers/stuck_ci_jobs_worker.rb
+1
-1
30708-stop-using-deleted-at-to-filter-namespaces.yml
...ased/30708-stop-using-deleted-at-to-filter-namespaces.yml
+4
-0
runner.rb
lib/api/helpers/runner.rb
+2
-1
helpers.rb
lib/ci/api/helpers.rb
+2
-1
todos_spec.rb
spec/features/dashboard/todos/todos_spec.rb
+0
-17
project_spec.rb
spec/models/project_spec.rb
+0
-9
No files found.
app/controllers/projects_controller.rb
View file @
c89f7c71
...
...
@@ -97,7 +97,7 @@ class ProjectsController < Projects::ApplicationController
end
if
@project
.
pending_delete?
flash
[
:alert
]
=
_
(
"Project '%{project_name}' queued for deletion."
)
%
{
project_name:
@project
.
name
}
flash
.
now
[
:alert
]
=
_
(
"Project '%{project_name}' queued for deletion."
)
%
{
project_name:
@project
.
name
}
end
respond_to
do
|
format
|
...
...
app/finders/todos_finder.rb
View file @
c89f7c71
...
...
@@ -83,6 +83,8 @@ class TodosFinder
if
project?
@project
=
Project
.
find
(
params
[
:project_id
])
@project
=
nil
if
@project
.
pending_delete?
unless
Ability
.
allowed?
(
current_user
,
:read_project
,
@project
)
@project
=
nil
end
...
...
app/models/namespace.rb
View file @
c89f7c71
...
...
@@ -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
...
...
app/models/notification_setting.rb
View file @
c89f7c71
...
...
@@ -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
=
[
...
...
app/models/project.rb
View file @
c89f7c71
...
...
@@ -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
##
...
...
app/services/ci/register_job_service.rb
View file @
c89f7c71
...
...
@@ -54,7 +54,7 @@ module Ci
def
builds_for_shared_runner
new_builds
.
# don't run projects which have not enabled shared runners and builds
joins
(
:project
).
where
(
projects:
{
shared_runners_enabled:
true
})
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'
)
.
where
(
'project_features.builds_access_level IS NULL or project_features.builds_access_level > 0'
)
.
...
...
@@ -66,7 +66,7 @@ module Ci
end
def
builds_for_specific_runner
new_builds
.
where
(
project:
runner
.
projects
.
with_builds_enabled
).
order
(
'created_at ASC'
)
new_builds
.
where
(
project:
runner
.
projects
.
with
out_deleted
.
with
_builds_enabled
).
order
(
'created_at ASC'
)
end
def
running_builds_for_shared_runners
...
...
app/services/groups/destroy_service.rb
View file @
c89f7c71
...
...
@@ -10,7 +10,7 @@ module Groups
def
execute
group
.
prepare_for_destroy
group
.
projects
.
with_deleted
.
each
do
|
project
|
group
.
projects
.
each
do
|
project
|
# Execute the destruction of the models immediately to ensure atomic cleanup.
# Skip repository removal because we remove directory with namespace
# that contain all these repositories
...
...
app/services/users/destroy_service.rb
View file @
c89f7c71
...
...
@@ -35,7 +35,7 @@ module Users
Groups
::
DestroyService
.
new
(
group
,
current_user
).
execute
end
user
.
personal_projects
.
with_deleted
.
each
do
|
project
|
user
.
personal_projects
.
each
do
|
project
|
# Skip repository removal because we remove directory with namespace
# that contain all this repositories
::
Projects
::
DestroyService
.
new
(
project
,
current_user
,
skip_repo:
true
).
execute
...
...
app/views/shared/projects/_list.html.haml
View file @
c89f7c71
...
...
@@ -13,7 +13,7 @@
-
if
projects
.
any?
%ul
.projects-list
-
projects
.
each_with_index
do
|
project
,
i
|
-
css_class
=
(
i
>=
projects_limit
)
?
'hide'
:
nil
-
css_class
=
(
i
>=
projects_limit
)
||
project
.
pending_delete?
?
'hide'
:
nil
=
render
"shared/projects/project"
,
project:
project
,
skip_namespace:
skip_namespace
,
avatar:
avatar
,
stars:
stars
,
css_class:
css_class
,
ci:
ci
,
use_creator_avatar:
use_creator_avatar
,
forks:
forks
,
show_last_commit_as_description:
show_last_commit_as_description
...
...
app/workers/stuck_ci_jobs_worker.rb
View file @
c89f7c71
...
...
@@ -45,7 +45,7 @@ class StuckCiJobsWorker
def
search
(
status
,
timeout
)
builds
=
Ci
::
Build
.
where
(
status:
status
).
where
(
'ci_builds.updated_at < ?'
,
timeout
.
ago
)
builds
.
joins
(
:project
).
includes
(
:tags
,
:runner
,
project: :namespace
).
find_each
(
batch_size:
50
).
each
do
|
build
|
builds
.
joins
(
:project
).
merge
(
Project
.
without_deleted
).
includes
(
:tags
,
:runner
,
project: :namespace
).
find_each
(
batch_size:
50
).
each
do
|
build
|
yield
(
build
)
end
end
...
...
changelogs/unreleased/30708-stop-using-deleted-at-to-filter-namespaces.yml
0 → 100644
View file @
c89f7c71
---
title
:
Removes deleted_at and pending_delete occurrences in Project related queries
merge_request
:
12091
author
:
lib/api/helpers/runner.rb
View file @
c89f7c71
...
...
@@ -46,7 +46,8 @@ module API
yield
if
block_given?
forbidden!
(
'Project has been deleted!'
)
unless
job
.
project
project
=
job
.
project
forbidden!
(
'Project has been deleted!'
)
if
project
.
nil?
||
project
.
pending_delete?
forbidden!
(
'Job has been erased!'
)
if
job
.
erased?
end
...
...
lib/ci/api/helpers.rb
View file @
c89f7c71
...
...
@@ -28,7 +28,8 @@ module Ci
yield
if
block_given?
forbidden!
(
'Project has been deleted!'
)
unless
build
.
project
project
=
build
.
project
forbidden!
(
'Project has been deleted!'
)
if
project
.
nil?
||
project
.
pending_delete?
forbidden!
(
'Build has been erased!'
)
if
build
.
erased?
end
...
...
spec/features/dashboard/todos/todos_spec.rb
View file @
c89f7c71
...
...
@@ -317,23 +317,6 @@ feature 'Dashboard Todos' do
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
let!
(
:todo
)
{
create
(
:todo
,
:build_failed
,
user:
user
,
project:
project
,
author:
author
)
}
...
...
spec/models/project_spec.rb
View file @
c89f7c71
...
...
@@ -284,15 +284,6 @@ describe Project, models: true do
end
end
describe
'default_scope'
do
it
'excludes projects pending deletion from the results'
do
project
=
create
(
:empty_project
)
create
(
:empty_project
,
pending_delete:
true
)
expect
(
Project
.
all
).
to
eq
[
project
]
end
end
describe
'project token'
do
it
'sets an random token if none provided'
do
project
=
FactoryGirl
.
create
:empty_project
,
runners_token:
''
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment