Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
34f57b46
Commit
34f57b46
authored
Jun 15, 2017
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix current feature related specs
parent
8e8eb978
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
21 additions
and
21 deletions
+21
-21
app/finders/todos_finder.rb
app/finders/todos_finder.rb
+4
-1
app/models/notification_setting.rb
app/models/notification_setting.rb
+1
-1
app/models/project.rb
app/models/project.rb
+1
-1
app/services/ci/register_job_service.rb
app/services/ci/register_job_service.rb
+4
-4
app/services/groups/destroy_service.rb
app/services/groups/destroy_service.rb
+1
-1
app/services/users/destroy_service.rb
app/services/users/destroy_service.rb
+1
-1
app/workers/stuck_ci_jobs_worker.rb
app/workers/stuck_ci_jobs_worker.rb
+1
-1
changelogs/unreleased/30708-stop-using-deleted-at-to-filter-namespaces.yml
...ased/30708-stop-using-deleted-at-to-filter-namespaces.yml
+4
-0
lib/api/helpers/runner.rb
lib/api/helpers/runner.rb
+2
-1
lib/ci/api/helpers.rb
lib/ci/api/helpers.rb
+2
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+0
-9
No files found.
app/finders/todos_finder.rb
View file @
34f57b46
...
@@ -78,11 +78,14 @@ class TodosFinder
...
@@ -78,11 +78,14 @@ 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?
@project
=
Project
.
find
(
params
[
:project_id
])
@project
=
Project
.
find
(
params
[
:project_id
])
@project
=
nil
if
@project
.
pending_delete?
unless
Ability
.
allowed?
(
current_user
,
:read_project
,
@project
)
unless
Ability
.
allowed?
(
current_user
,
:read_project
,
@project
)
@project
=
nil
@project
=
nil
end
end
...
@@ -95,7 +98,7 @@ class TodosFinder
...
@@ -95,7 +98,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
ProjectsFinder
.
new
(
current_user:
current_user
,
project_ids_relation:
item_project_ids
).
execute
.
without_deleted
end
end
def
type?
def
type?
...
...
app/models/notification_setting.rb
View file @
34f57b46
...
@@ -19,7 +19,7 @@ class NotificationSetting < ActiveRecord::Base
...
@@ -19,7 +19,7 @@ class NotificationSetting < ActiveRecord::Base
# pending delete).
# pending delete).
#
#
scope
:for_projects
,
->
do
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
end
EMAIL_EVENTS
=
[
EMAIL_EVENTS
=
[
...
...
app/models/project.rb
View file @
34f57b46
...
@@ -1456,7 +1456,7 @@ class Project < ActiveRecord::Base
...
@@ -1456,7 +1456,7 @@ class Project < ActiveRecord::Base
def
pending_delete_twin
def
pending_delete_twin
return
false
unless
path
return
false
unless
path
Project
.
unscoped
.
where
(
pending_delete:
true
)
.
find_by_full_path
(
path_with_namespace
)
Project
.
with_deleted
.
find_by_full_path
(
path_with_namespace
)
end
end
##
##
...
...
app/services/ci/register_job_service.rb
View file @
34f57b46
...
@@ -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
})
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
...
@@ -66,7 +66,7 @@ module Ci
...
@@ -66,7 +66,7 @@ module Ci
end
end
def
builds_for_specific_runner
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
end
def
running_builds_for_shared_runners
def
running_builds_for_shared_runners
...
...
app/services/groups/destroy_service.rb
View file @
34f57b46
...
@@ -10,7 +10,7 @@ module Groups
...
@@ -10,7 +10,7 @@ module Groups
def
execute
def
execute
group
.
prepare_for_destroy
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.
# Execute the destruction of the models immediately to ensure atomic cleanup.
# Skip repository removal because we remove directory with namespace
# Skip repository removal because we remove directory with namespace
# that contain all these repositories
# that contain all these repositories
...
...
app/services/users/destroy_service.rb
View file @
34f57b46
...
@@ -35,7 +35,7 @@ module Users
...
@@ -35,7 +35,7 @@ module Users
Groups
::
DestroyService
.
new
(
group
,
current_user
).
execute
Groups
::
DestroyService
.
new
(
group
,
current_user
).
execute
end
end
user
.
personal_projects
.
with_deleted
.
each
do
|
project
|
user
.
personal_projects
.
each
do
|
project
|
# Skip repository removal because we remove directory with namespace
# Skip repository removal because we remove directory with namespace
# that contain all this repositories
# that contain all this repositories
::
Projects
::
DestroyService
.
new
(
project
,
current_user
,
skip_repo:
true
).
execute
::
Projects
::
DestroyService
.
new
(
project
,
current_user
,
skip_repo:
true
).
execute
...
...
app/workers/stuck_ci_jobs_worker.rb
View file @
34f57b46
...
@@ -45,7 +45,7 @@ class StuckCiJobsWorker
...
@@ -45,7 +45,7 @@ class StuckCiJobsWorker
def
search
(
status
,
timeout
)
def
search
(
status
,
timeout
)
builds
=
Ci
::
Build
.
where
(
status:
status
).
where
(
'ci_builds.updated_at < ?'
,
timeout
.
ago
)
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
)
yield
(
build
)
end
end
end
end
...
...
changelogs/unreleased/30708-stop-using-deleted-at-to-filter-namespaces.yml
0 → 100644
View file @
34f57b46
---
title
:
Removes deleted_at and pending_delete occurrences in Project related queries
merge_request
:
12091
author
:
lib/api/helpers/runner.rb
View file @
34f57b46
...
@@ -46,7 +46,8 @@ module API
...
@@ -46,7 +46,8 @@ module API
yield
if
block_given?
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?
forbidden!
(
'Job has been erased!'
)
if
job
.
erased?
end
end
...
...
lib/ci/api/helpers.rb
View file @
34f57b46
...
@@ -28,7 +28,8 @@ module Ci
...
@@ -28,7 +28,8 @@ module Ci
yield
if
block_given?
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?
forbidden!
(
'Build has been erased!'
)
if
build
.
erased?
end
end
...
...
spec/models/project_spec.rb
View file @
34f57b46
...
@@ -284,15 +284,6 @@ describe Project, models: true do
...
@@ -284,15 +284,6 @@ describe Project, models: true do
end
end
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
describe
'project token'
do
it
'sets an random token if none provided'
do
it
'sets an random token if none provided'
do
project
=
FactoryGirl
.
create
:empty_project
,
runners_token:
''
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