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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
692bedf5
Commit
692bedf5
authored
Jun 24, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
970241d5
2b2d2911
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
47 additions
and
9 deletions
+47
-9
app/assets/javascripts/jobs/components/job_log_controllers.vue
...ssets/javascripts/jobs/components/job_log_controllers.vue
+3
-5
app/assets/javascripts/jobs/components/sidebar.vue
app/assets/javascripts/jobs/components/sidebar.vue
+4
-1
app/controllers/dashboard/todos_controller.rb
app/controllers/dashboard/todos_controller.rb
+1
-0
app/helpers/todos_helper.rb
app/helpers/todos_helper.rb
+1
-1
app/models/todo.rb
app/models/todo.rb
+1
-1
changelogs/unreleased/sh-optimize-todos-controller.yml
changelogs/unreleased/sh-optimize-todos-controller.yml
+5
-0
lib/api/todos.rb
lib/api/todos.rb
+1
-1
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/controllers/dashboard/todos_controller_spec.rb
spec/controllers/dashboard/todos_controller_spec.rb
+28
-0
No files found.
app/assets/javascripts/jobs/components/job_log_controllers.vue
View file @
692bedf5
...
@@ -3,7 +3,7 @@ import { GlTooltipDirective, GlLink, GlButton } from '@gitlab/ui';
...
@@ -3,7 +3,7 @@ import { GlTooltipDirective, GlLink, GlButton } from '@gitlab/ui';
import
{
polyfillSticky
}
from
'
~/lib/utils/sticky
'
;
import
{
polyfillSticky
}
from
'
~/lib/utils/sticky
'
;
import
Icon
from
'
~/vue_shared/components/icon.vue
'
;
import
Icon
from
'
~/vue_shared/components/icon.vue
'
;
import
{
numberToHumanSize
}
from
'
~/lib/utils/number_utils
'
;
import
{
numberToHumanSize
}
from
'
~/lib/utils/number_utils
'
;
import
{
sprintf
}
from
'
~/locale
'
;
import
{
__
,
sprintf
}
from
'
~/locale
'
;
import
scrollDown
from
'
../svg/scroll_down.svg
'
;
import
scrollDown
from
'
../svg/scroll_down.svg
'
;
export
default
{
export
default
{
...
@@ -50,7 +50,7 @@ export default {
...
@@ -50,7 +50,7 @@ export default {
},
},
computed
:
{
computed
:
{
jobLogSize
()
{
jobLogSize
()
{
return
sprintf
(
'
Showing last %{size} of log -
'
,
{
return
sprintf
(
__
(
'
Showing last %{size} of log -
'
)
,
{
size
:
numberToHumanSize
(
this
.
size
),
size
:
numberToHumanSize
(
this
.
size
),
});
});
},
},
...
@@ -74,14 +74,12 @@ export default {
...
@@ -74,14 +74,12 @@ export default {
<div
class=
"js-truncated-info truncated-info d-none d-sm-block float-left"
>
<div
class=
"js-truncated-info truncated-info d-none d-sm-block float-left"
>
<template
v-if=
"isTraceSizeVisible"
>
<template
v-if=
"isTraceSizeVisible"
>
{{
jobLogSize
}}
{{
jobLogSize
}}
<gl-link
<gl-link
v-if=
"rawPath"
v-if=
"rawPath"
:href=
"rawPath"
:href=
"rawPath"
class=
"js-raw-link text-plain text-underline prepend-left-5"
class=
"js-raw-link text-plain text-underline prepend-left-5"
>
{{
s__
(
'
Job|Complete Raw
'
)
}}
</gl-link
>
>
{{
s__
(
'
Job|Complete Raw
'
)
}}
</gl-link>
</
template
>
</
template
>
</div>
</div>
<!-- eo truncate information -->
<!-- eo truncate information -->
...
...
app/assets/javascripts/jobs/components/sidebar.vue
View file @
692bedf5
<
script
>
<
script
>
import
{
__
,
sprintf
}
from
'
~/locale
'
;
import
_
from
'
underscore
'
;
import
_
from
'
underscore
'
;
import
{
mapActions
,
mapState
}
from
'
vuex
'
;
import
{
mapActions
,
mapState
}
from
'
vuex
'
;
import
{
GlLink
,
GlButton
}
from
'
@gitlab/ui
'
;
import
{
GlLink
,
GlButton
}
from
'
@gitlab/ui
'
;
...
@@ -63,7 +64,9 @@ export default {
...
@@ -63,7 +64,9 @@ export default {
let
t
=
this
.
job
.
metadata
.
timeout_human_readable
;
let
t
=
this
.
job
.
metadata
.
timeout_human_readable
;
if
(
this
.
job
.
metadata
.
timeout_source
!==
''
)
{
if
(
this
.
job
.
metadata
.
timeout_source
!==
''
)
{
t
+=
` (from
${
this
.
job
.
metadata
.
timeout_source
}
)`
;
t
+=
sprintf
(
__
(
` (from %{timeoutSource})`
),
{
timeoutSource
:
this
.
job
.
metadata
.
timeout_source
,
});
}
}
return
t
;
return
t
;
...
...
app/controllers/dashboard/todos_controller.rb
View file @
692bedf5
...
@@ -10,6 +10,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController
...
@@ -10,6 +10,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController
def
index
def
index
@sort
=
params
[
:sort
]
@sort
=
params
[
:sort
]
@todos
=
@todos
.
page
(
params
[
:page
])
@todos
=
@todos
.
page
(
params
[
:page
])
@todos
=
@todos
.
with_entity_associations
return
if
redirect_out_of_range
(
@todos
)
return
if
redirect_out_of_range
(
@todos
)
end
end
...
...
app/helpers/todos_helper.rb
View file @
692bedf5
...
@@ -170,7 +170,7 @@ module TodosHelper
...
@@ -170,7 +170,7 @@ module TodosHelper
end
end
def
todo_group_options
def
todo_group_options
groups
=
current_user
.
authorized_groups
.
map
do
|
group
|
groups
=
current_user
.
authorized_groups
.
with_route
.
map
do
|
group
|
{
id:
group
.
id
,
text:
group
.
full_name
}
{
id:
group
.
id
,
text:
group
.
full_name
}
end
end
...
...
app/models/todo.rb
View file @
692bedf5
...
@@ -60,7 +60,7 @@ class Todo < ApplicationRecord
...
@@ -60,7 +60,7 @@ class Todo < ApplicationRecord
scope
:for_type
,
->
(
type
)
{
where
(
target_type:
type
)
}
scope
:for_type
,
->
(
type
)
{
where
(
target_type:
type
)
}
scope
:for_target
,
->
(
id
)
{
where
(
target_id:
id
)
}
scope
:for_target
,
->
(
id
)
{
where
(
target_id:
id
)
}
scope
:for_commit
,
->
(
id
)
{
where
(
commit_id:
id
)
}
scope
:for_commit
,
->
(
id
)
{
where
(
commit_id:
id
)
}
scope
:with_
api_
entity_associations
,
->
{
preload
(
:target
,
:author
,
:note
,
group: :route
,
project:
[
:route
,
{
namespace: :route
}])
}
scope
:with_entity_associations
,
->
{
preload
(
:target
,
:author
,
:note
,
group: :route
,
project:
[
:route
,
{
namespace: :route
}])
}
scope
:joins_issue_and_assignees
,
->
{
left_joins
(
issue: :assignees
)
}
scope
:joins_issue_and_assignees
,
->
{
left_joins
(
issue: :assignees
)
}
state_machine
:state
,
initial: :pending
do
state_machine
:state
,
initial: :pending
do
...
...
changelogs/unreleased/sh-optimize-todos-controller.yml
0 → 100644
View file @
692bedf5
---
title
:
Eliminate N+1 queries in Dashboard::TodosController
merge_request
:
29954
author
:
type
:
performance
lib/api/todos.rb
View file @
692bedf5
...
@@ -78,7 +78,7 @@ module API
...
@@ -78,7 +78,7 @@ module API
use
:pagination
use
:pagination
end
end
get
do
get
do
todos
=
paginate
(
find_todos
.
with_
api_
entity_associations
)
todos
=
paginate
(
find_todos
.
with_entity_associations
)
options
=
{
with:
Entities
::
Todo
,
current_user:
current_user
}
options
=
{
with:
Entities
::
Todo
,
current_user:
current_user
}
batch_load_issuable_metadata
(
todos
,
options
)
batch_load_issuable_metadata
(
todos
,
options
)
...
...
locale/gitlab.pot
View file @
692bedf5
...
@@ -16,6 +16,9 @@ msgstr ""
...
@@ -16,6 +16,9 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
msgid " (from %{timeoutSource})"
msgstr ""
msgid " Please sign in."
msgid " Please sign in."
msgstr ""
msgstr ""
...
...
spec/controllers/dashboard/todos_controller_spec.rb
View file @
692bedf5
...
@@ -44,6 +44,34 @@ describe Dashboard::TodosController do
...
@@ -44,6 +44,34 @@ describe Dashboard::TodosController do
end
end
end
end
context
"with render_views"
do
render_views
it
'avoids N+1 queries'
,
:request_store
do
merge_request
=
create
(
:merge_request
,
source_project:
project
)
create
(
:todo
,
project:
project
,
author:
author
,
user:
user
,
target:
merge_request
)
create
(
:issue
,
project:
project
,
assignees:
[
user
])
group
=
create
(
:group
)
group
.
add_owner
(
user
)
get
:index
control
=
ActiveRecord
::
QueryRecorder
.
new
{
get
:index
}
create
(
:issue
,
project:
project
,
assignees:
[
user
])
group_2
=
create
(
:group
)
group_2
.
add_owner
(
user
)
project_2
=
create
(
:project
)
project_2
.
add_developer
(
user
)
merge_request_2
=
create
(
:merge_request
,
source_project:
project_2
)
create
(
:todo
,
project:
project
,
author:
author
,
user:
user
,
target:
merge_request_2
)
expect
{
get
:index
}.
not_to
exceed_query_limit
(
control
)
expect
(
response
.
status
).
to
eq
(
200
)
end
end
context
'group authorization'
do
context
'group authorization'
do
it
'renders 404 when user does not have read access on given group'
do
it
'renders 404 when user does not have read access on given group'
do
unauthorized_group
=
create
(
:group
,
:private
)
unauthorized_group
=
create
(
:group
,
:private
)
...
...
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