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
1e7116b3
Commit
1e7116b3
authored
Mar 29, 2016
by
Zeger-Jan van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Exclude projects pending deletion from all results
parent
95c7aa62
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
33 additions
and
12 deletions
+33
-12
CHANGELOG
CHANGELOG
+1
-0
app/models/project.rb
app/models/project.rb
+2
-0
app/services/system_hooks_service.rb
app/services/system_hooks_service.rb
+12
-10
app/workers/project_destroy_worker.rb
app/workers/project_destroy_worker.rb
+1
-1
db/migrate/20160329144452_add_index_on_pending_delete_projects.rb
...te/20160329144452_add_index_on_pending_delete_projects.rb
+6
-0
db/schema.rb
db/schema.rb
+2
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+9
-0
No files found.
CHANGELOG
View file @
1e7116b3
...
@@ -10,6 +10,7 @@ v 8.7.0 (unreleased)
...
@@ -10,6 +10,7 @@ v 8.7.0 (unreleased)
- Fix raw/rendered diff producing different results on merge requests !3450
- Fix raw/rendered diff producing different results on merge requests !3450
- Add links to CI setup documentation from project settings and builds pages
- Add links to CI setup documentation from project settings and builds pages
- Handle nil descriptions in Slack issue messages (Stan Hu)
- Handle nil descriptions in Slack issue messages (Stan Hu)
- Add default scope to projects to exclude projects pending deletion
- Implement 'Groups View' as an option for dashboard preferences !3379 (Elias W.)
- Implement 'Groups View' as an option for dashboard preferences !3379 (Elias W.)
- Implement 'TODOs View' as an option for dashboard preferences !3379 (Elias W.)
- Implement 'TODOs View' as an option for dashboard preferences !3379 (Elias W.)
- Gracefully handle notes on deleted commits in merge requests (Stan Hu)
- Gracefully handle notes on deleted commits in merge requests (Stan Hu)
...
...
app/models/project.rb
View file @
1e7116b3
...
@@ -206,6 +206,8 @@ class Project < ActiveRecord::Base
...
@@ -206,6 +206,8 @@ class Project < ActiveRecord::Base
mount_uploader
:avatar
,
AvatarUploader
mount_uploader
:avatar
,
AvatarUploader
# Scopes
# Scopes
default_scope
{
where
(
pending_delete:
false
)
}
scope
:sorted_by_activity
,
->
{
reorder
(
last_activity_at: :desc
)
}
scope
:sorted_by_activity
,
->
{
reorder
(
last_activity_at: :desc
)
}
scope
:sorted_by_stars
,
->
{
reorder
(
'projects.star_count DESC'
)
}
scope
:sorted_by_stars
,
->
{
reorder
(
'projects.star_count DESC'
)
}
scope
:sorted_by_names
,
->
{
joins
(
:namespace
).
reorder
(
'namespaces.name ASC, projects.name ASC'
)
}
scope
:sorted_by_names
,
->
{
joins
(
:namespace
).
reorder
(
'namespaces.name ASC, projects.name ASC'
)
}
...
...
app/services/system_hooks_service.rb
View file @
1e7116b3
...
@@ -95,17 +95,19 @@ class SystemHooksService
...
@@ -95,17 +95,19 @@ class SystemHooksService
end
end
def
project_member_data
(
model
)
def
project_member_data
(
model
)
project
=
model
.
project
||
Project
.
unscoped
.
find
(
model
.
source_id
)
{
{
project_name:
model
.
project
.
name
,
project_name:
project
.
name
,
project_path:
model
.
project
.
path
,
project_path:
project
.
path
,
project_path_with_namespace:
model
.
project
.
path_with_namespace
,
project_path_with_namespace:
project
.
path_with_namespace
,
project_id:
model
.
project
.
id
,
project_id:
project
.
id
,
user_username:
model
.
user
.
username
,
user_username:
model
.
user
.
username
,
user_name:
model
.
user
.
name
,
user_name:
model
.
user
.
name
,
user_email:
model
.
user
.
email
,
user_email:
model
.
user
.
email
,
user_id:
model
.
user
.
id
,
user_id:
model
.
user
.
id
,
access_level:
model
.
human_access
,
access_level:
model
.
human_access
,
project_visibility:
Project
.
visibility_levels
.
key
(
model
.
project
.
visibility_level_field
).
downcase
project_visibility:
Project
.
visibility_levels
.
key
(
project
.
visibility_level_field
).
downcase
}
}
end
end
...
...
app/workers/project_destroy_worker.rb
View file @
1e7116b3
...
@@ -5,7 +5,7 @@ class ProjectDestroyWorker
...
@@ -5,7 +5,7 @@ class ProjectDestroyWorker
def
perform
(
project_id
,
user_id
,
params
)
def
perform
(
project_id
,
user_id
,
params
)
begin
begin
project
=
Project
.
find
(
project_id
)
project
=
Project
.
unscoped
.
find
(
project_id
)
rescue
ActiveRecord
::
RecordNotFound
rescue
ActiveRecord
::
RecordNotFound
return
return
end
end
...
...
db/migrate/20160329144452_add_index_on_pending_delete_projects.rb
0 → 100644
View file @
1e7116b3
class
AddIndexOnPendingDeleteProjects
<
ActiveRecord
::
Migration
def
change
add_index
:projects
,
:pending_delete
end
end
db/schema.rb
View file @
1e7116b3
...
@@ -418,7 +418,7 @@ ActiveRecord::Schema.define(version: 20160331133914) do
...
@@ -418,7 +418,7 @@ ActiveRecord::Schema.define(version: 20160331133914) do
t
.
integer
"iid"
t
.
integer
"iid"
t
.
integer
"updated_by_id"
t
.
integer
"updated_by_id"
t
.
integer
"moved_to_id"
t
.
integer
"moved_to_id"
t
.
boolean
"confidential"
,
default:
false
t
.
boolean
"confidential"
,
default:
false
t
.
datetime
"deleted_at"
t
.
datetime
"deleted_at"
end
end
...
@@ -745,6 +745,7 @@ ActiveRecord::Schema.define(version: 20160331133914) do
...
@@ -745,6 +745,7 @@ ActiveRecord::Schema.define(version: 20160331133914) do
add_index
"projects"
,
[
"namespace_id"
],
name:
"index_projects_on_namespace_id"
,
using: :btree
add_index
"projects"
,
[
"namespace_id"
],
name:
"index_projects_on_namespace_id"
,
using: :btree
add_index
"projects"
,
[
"path"
],
name:
"index_projects_on_path"
,
using: :btree
add_index
"projects"
,
[
"path"
],
name:
"index_projects_on_path"
,
using: :btree
add_index
"projects"
,
[
"path"
],
name:
"index_projects_on_path_trigram"
,
using: :gin
,
opclasses:
{
"path"
=>
"gin_trgm_ops"
}
add_index
"projects"
,
[
"path"
],
name:
"index_projects_on_path_trigram"
,
using: :gin
,
opclasses:
{
"path"
=>
"gin_trgm_ops"
}
add_index
"projects"
,
[
"pending_delete"
],
name:
"index_projects_on_pending_delete"
,
using: :btree
add_index
"projects"
,
[
"runners_token"
],
name:
"index_projects_on_runners_token"
,
using: :btree
add_index
"projects"
,
[
"runners_token"
],
name:
"index_projects_on_runners_token"
,
using: :btree
add_index
"projects"
,
[
"star_count"
],
name:
"index_projects_on_star_count"
,
using: :btree
add_index
"projects"
,
[
"star_count"
],
name:
"index_projects_on_star_count"
,
using: :btree
add_index
"projects"
,
[
"visibility_level"
],
name:
"index_projects_on_visibility_level"
,
using: :btree
add_index
"projects"
,
[
"visibility_level"
],
name:
"index_projects_on_visibility_level"
,
using: :btree
...
...
spec/models/project_spec.rb
View file @
1e7116b3
...
@@ -104,6 +104,15 @@ describe Project, models: true do
...
@@ -104,6 +104,15 @@ 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
'should set an random token if none provided'
do
it
'should set 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