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
Léo-Paul Géneau
gitlab-ce
Commits
4b0fb028
Commit
4b0fb028
authored
Feb 03, 2014
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not load all projects all the time.
parent
70fb26a6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
14 deletions
+20
-14
app/services/filtering_service.rb
app/services/filtering_service.rb
+20
-14
No files found.
app/services/filtering_service.rb
View file @
4b0fb028
...
@@ -24,10 +24,10 @@ class FilteringService
...
@@ -24,10 +24,10 @@ class FilteringService
@current_user
=
current_user
@current_user
=
current_user
@params
=
params
@params
=
params
items
=
by_scope
items
=
init_collection
items
=
by_scope
(
items
)
items
=
by_state
(
items
)
items
=
by_state
(
items
)
items
=
by_group
(
items
)
items
=
by_group
(
items
)
items
=
by_project
(
items
)
items
=
by_search
(
items
)
items
=
by_search
(
items
)
items
=
by_milestone
(
items
)
items
=
by_milestone
(
items
)
items
=
by_assignee
(
items
)
items
=
by_assignee
(
items
)
...
@@ -37,24 +37,30 @@ class FilteringService
...
@@ -37,24 +37,30 @@ class FilteringService
private
private
def
by_scope
def
init_collection
table_name
=
klass
.
table_name
table_name
=
klass
.
table_name
case
params
[
:scope
]
return
klass
.
of_projects
(
Project
.
public_only
)
unless
current_user
when
'created-by-me'
,
'authored'
then
current_user
.
send
(
table_name
)
if
project
when
'all'
then
if
current_user
.
can?
(
:read_project
,
project
)
if
current_user
project
.
send
(
table_name
)
if
project
&&
(
project
.
public?
||
project
.
internal?
)
klass
.
of_projects
(
Project
.
public_or_internal_only
(
current_user
))
else
else
klass
.
of_projects
(
current_user
.
authorized_projects
.
pluck
(
:id
))
[]
end
end
else
else
klass
.
of_projects
(
Project
.
public_only
)
klass
.
of_projects
(
current_user
.
authorized_projects
)
end
end
end
def
by_scope
(
items
)
case
params
[
:scope
]
when
'created-by-me'
,
'authored'
then
klass
.
where
(
author_id:
current_user
.
id
)
when
'all'
then
klass
when
'assigned-to-me'
then
when
'assigned-to-me'
then
current_user
.
send
(
"assigned_
#{
table_name
}
"
)
klass
.
where
(
assignee_id:
current_user
.
id
)
else
else
raise
'You must specify default scope'
raise
'You must specify default scope'
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