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
4ad51baed18d
Commit
4b0fb028
authored
Feb 03, 2014
by
Marin Jankovski
Browse files
Do not load all projects all the time.
parent
e9ef92568193
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/services/filtering_service.rb
View file @
4ad51bae
...
...
@@ -24,10 +24,10 @@ def execute(klass, current_user, params)
@current_user
=
current_user
@params
=
params
items
=
by_scope
items
=
init_collection
items
=
by_scope
(
items
)
items
=
by_state
(
items
)
items
=
by_group
(
items
)
items
=
by_project
(
items
)
items
=
by_search
(
items
)
items
=
by_milestone
(
items
)
items
=
by_assignee
(
items
)
...
...
@@ -37,24 +37,30 @@ def execute(klass, current_user, params)
private
def
by_scope
def
init_collection
table_name
=
klass
.
table_name
return
klass
.
of_projects
(
Project
.
public_only
)
unless
current_user
if
project
if
current_user
.
can?
(
:read_project
,
project
)
project
.
send
(
table_name
)
else
[]
end
else
klass
.
of_projects
(
current_user
.
authorized_projects
)
end
end
def
by_scope
(
items
)
case
params
[
:scope
]
when
'created-by-me'
,
'authored'
then
current_user
.
send
(
table_name
)
klass
.
where
(
author_id:
current_user
.
id
)
when
'all'
then
if
current_user
if
project
&&
(
project
.
public?
||
project
.
internal?
)
klass
.
of_projects
(
Project
.
public_or_internal_only
(
current_user
))
else
klass
.
of_projects
(
current_user
.
authorized_projects
.
pluck
(
:id
))
end
else
klass
.
of_projects
(
Project
.
public_only
)
end
klass
when
'assigned-to-me'
then
current_user
.
send
(
"assigned_
#{
table_name
}
"
)
klass
.
where
(
assignee_id:
current_user
.
id
)
else
raise
'You must specify default scope'
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