Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
f7237937a7ca
Commit
f7237937
authored
Mar 29, 2016
by
Zeger-Jan van de Weg
Browse files
Exclude projects pending deletion from all results
parent
802aeb7e7a78
Changes
7
Hide whitespace changes
Inline
Side-by-side
CHANGELOG
View file @
f7237937
...
...
@@ -10,6 +10,7 @@
- Fix raw/rendered diff producing different results on merge requests !3450
- Add links to CI setup documentation from project settings and builds pages
- 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 'TODOs View' as an option for dashboard preferences !3379 (Elias W.)
- Gracefully handle notes on deleted commits in merge requests (Stan Hu)
...
...
app/models/project.rb
View file @
f7237937
...
...
@@ -206,6 +206,8 @@
mount_uploader
:avatar
,
AvatarUploader
# Scopes
default_scope
{
where
(
pending_delete:
false
)
}
scope
:sorted_by_activity
,
->
{
reorder
(
last_activity_at: :desc
)
}
scope
:sorted_by_stars
,
->
{
reorder
(
'projects.star_count DESC'
)
}
scope
:sorted_by_names
,
->
{
joins
(
:namespace
).
reorder
(
'namespaces.name ASC, projects.name ASC'
)
}
...
...
app/services/system_hooks_service.rb
View file @
f7237937
...
...
@@ -95,4 +95,6 @@
end
def
project_member_data
(
model
)
project
=
model
.
project
||
Project
.
unscoped
.
find
(
model
.
source_id
)
{
...
...
@@ -98,14 +100,14 @@
{
project_name:
model
.
project
.
name
,
project_path:
model
.
project
.
path
,
project_path_with_namespace:
model
.
project
.
path_with_namespace
,
project_id:
model
.
project
.
id
,
user_username:
model
.
user
.
username
,
user_name:
model
.
user
.
name
,
user_email:
model
.
user
.
email
,
user_id:
model
.
user
.
id
,
access_level:
model
.
human_access
,
project_visibility:
Project
.
visibility_levels
.
key
(
model
.
project
.
visibility_level_field
).
downcase
project_name:
project
.
name
,
project_path:
project
.
path
,
project_path_with_namespace:
project
.
path_with_namespace
,
project_id:
project
.
id
,
user_username:
model
.
user
.
username
,
user_name:
model
.
user
.
name
,
user_email:
model
.
user
.
email
,
user_id:
model
.
user
.
id
,
access_level:
model
.
human_access
,
project_visibility:
Project
.
visibility_levels
.
key
(
project
.
visibility_level_field
).
downcase
}
end
...
...
app/workers/project_destroy_worker.rb
View file @
f7237937
...
...
@@ -5,7 +5,7 @@
def
perform
(
project_id
,
user_id
,
params
)
begin
project
=
Project
.
find
(
project_id
)
project
=
Project
.
unscoped
.
find
(
project_id
)
rescue
ActiveRecord
::
RecordNotFound
return
end
...
...
db/migrate/20160329144452_add_index_on_pending_delete_projects.rb
0 → 100644
View file @
f7237937
class
AddIndexOnPendingDeleteProjects
<
ActiveRecord
::
Migration
def
change
add_index
:projects
,
:pending_delete
end
end
db/schema.rb
View file @
f7237937
...
...
@@ -418,7 +418,7 @@
t
.
integer
"iid"
t
.
integer
"updated_by_id"
t
.
integer
"moved_to_id"
t
.
boolean
"confidential"
,
default:
false
t
.
boolean
"confidential"
,
default:
false
t
.
datetime
"deleted_at"
end
...
...
@@ -745,6 +745,7 @@
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_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"
,
[
"star_count"
],
name:
"index_projects_on_star_count"
,
using: :btree
add_index
"projects"
,
[
"visibility_level"
],
name:
"index_projects_on_visibility_level"
,
using: :btree
...
...
spec/models/project_spec.rb
View file @
f7237937
...
...
@@ -104,6 +104,15 @@
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
'should set an random token if none provided'
do
project
=
FactoryGirl
.
create
:empty_project
,
runners_token:
''
...
...
Write
Preview
Supports
Markdown
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