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
Kazuhiko Shiozaki
gitlab-ce
Commits
d075df56
Commit
d075df56
authored
Dec 30, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve perfomance of removeing group
parent
f45345ed
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
1 deletion
+27
-1
app/controllers/admin/groups_controller.rb
app/controllers/admin/groups_controller.rb
+2
-0
app/models/group.rb
app/models/group.rb
+4
-0
app/models/users_project.rb
app/models/users_project.rb
+19
-0
app/roles/team.rb
app/roles/team.rb
+2
-1
No files found.
app/controllers/admin/groups_controller.rb
View file @
d075df56
...
@@ -73,6 +73,8 @@ class Admin::GroupsController < AdminController
...
@@ -73,6 +73,8 @@ class Admin::GroupsController < AdminController
end
end
def
destroy
def
destroy
@group
.
truncate_teams
@group
.
destroy
@group
.
destroy
redirect_to
admin_groups_path
,
notice:
'Group was successfully deleted.'
redirect_to
admin_groups_path
,
notice:
'Group was successfully deleted.'
...
...
app/models/group.rb
View file @
d075df56
...
@@ -29,4 +29,8 @@ class Group < Namespace
...
@@ -29,4 +29,8 @@ class Group < Namespace
def
human_name
def
human_name
name
name
end
end
def
truncate_teams
UsersProject
.
truncate_teams
(
project_ids
)
end
end
end
app/models/users_project.rb
View file @
d075df56
...
@@ -56,6 +56,25 @@ class UsersProject < ActiveRecord::Base
...
@@ -56,6 +56,25 @@ class UsersProject < ActiveRecord::Base
false
false
end
end
def
truncate_teams
(
project_ids
)
UsersProject
.
transaction
do
users_projects
=
UsersProject
.
where
(
project_id:
project_ids
)
users_projects
.
each
do
|
users_project
|
users_project
.
skip_git
=
true
users_project
.
destroy
end
Gitlab
::
Gitolite
.
new
.
update_repositories
(
Project
.
where
(
id:
project_ids
))
end
true
rescue
false
end
def
truncate_team
project
truncate_teams
[
project
.
id
]
end
def
import_team
(
source_project
,
target_project
)
def
import_team
(
source_project
,
target_project
)
source_team
=
source_project
.
users_projects
.
all
source_team
=
source_project
.
users_projects
.
all
target_team
=
target_project
.
users_projects
.
all
target_team
=
target_project
.
users_projects
.
all
...
...
app/roles/team.rb
View file @
d075df56
...
@@ -47,7 +47,8 @@ module Team
...
@@ -47,7 +47,8 @@ module Team
UsersProject
.
bulk_delete
(
self
,
users_ids
)
UsersProject
.
bulk_delete
(
self
,
users_ids
)
end
end
# Remove all users from project team
def
truncate_team
def
truncate_team
UsersProject
.
bulk_delete
(
self
,
self
.
users
.
map
(
&
:id
)
)
UsersProject
.
truncate_team
(
self
)
end
end
end
end
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