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
Tatuya Kamada
gitlab-ce
Commits
504a1fac
Commit
504a1fac
authored
May 10, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix SQL queries for calculating stages status
parent
7c1acb02
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
13 deletions
+14
-13
app/models/commit_status.rb
app/models/commit_status.rb
+7
-5
app/views/projects/commit/_ci_commit.html.haml
app/views/projects/commit/_ci_commit.html.haml
+2
-3
app/views/projects/commit/_ci_stage.html.haml
app/views/projects/commit/_ci_stage.html.haml
+5
-5
No files found.
app/models/commit_status.rb
View file @
504a1fac
...
@@ -51,7 +51,7 @@ class CommitStatus < ActiveRecord::Base
...
@@ -51,7 +51,7 @@ class CommitStatus < ActiveRecord::Base
alias_attribute
:author
,
:user
alias_attribute
:author
,
:user
scope
:latest
,
->
{
where
(
id:
unscope
(
:select
).
select
(
'max(id)'
).
group
(
:name
,
:commit_id
))
}
scope
:latest
,
->
{
where
(
id:
unscope
(
:select
).
select
(
'max(id)'
).
group
(
:name
,
:commit_id
))
}
scope
:ordered
,
->
{
order
(
:
ref
,
:stage_idx
,
:
name
)
}
scope
:ordered
,
->
{
order
(
:name
)
}
scope
:ignored
,
->
{
where
(
allow_failure:
true
,
status:
[
:failed
,
:canceled
])
}
scope
:ignored
,
->
{
where
(
allow_failure:
true
,
status:
[
:failed
,
:canceled
])
}
state_machine
:status
,
initial: :pending
do
state_machine
:status
,
initial: :pending
do
...
@@ -91,13 +91,15 @@ class CommitStatus < ActiveRecord::Base
...
@@ -91,13 +91,15 @@ class CommitStatus < ActiveRecord::Base
end
end
def
self
.
stages
def
self
.
stages
order_by
=
'max(stage_idx)'
# We group by stage name, but order stages by their's index
CommitStatus
.
where
(
id:
all
).
group
(
'stage'
).
order
(
order_by
).
pluck
(
:stage
,
order_by
).
map
(
&
:first
).
compact
unscoped
.
from
(
all
,
:sg
).
group
(
'stage'
).
order
(
'max(stage_idx)'
,
'stage'
).
pluck
(
'sg.stage'
)
end
end
def
self
.
stages_status
def
self
.
stages_status
all
.
stages
.
inject
({})
do
|
h
,
stage
|
# We execute subquery for each of the stages which calculates an Stage Status
h
[
stage
]
=
all
.
where
(
stage:
stage
).
status
statuses
=
unscoped
.
from
(
all
,
:sg
).
group
(
'stage'
).
pluck
(
'sg.stage'
,
all
.
where
(
'stage=sg.stage'
).
status_sql
)
statuses
.
inject
({})
do
|
h
,
k
|
h
[
k
.
first
]
=
k
.
last
h
h
end
end
end
end
...
...
app/views/projects/commit/_ci_commit.html.haml
View file @
504a1fac
...
@@ -36,6 +36,5 @@
...
@@ -36,6 +36,5 @@
.table-holder
.table-holder
%table
.table.builds
%table
.table.builds
-
stages
=
ci_commit
.
statuses
.
latest
.
stages_status
-
ci_commit
.
statuses
.
stages
.
each
do
|
stage
|
-
stages
.
each
do
|
stage
,
status
|
=
render
'projects/commit/ci_stage'
,
stage:
stage
,
statuses:
ci_commit
.
statuses
.
where
(
stage:
stage
)
=
render
'ci_stage'
,
stage:
stage
,
status:
status
app/views/projects/commit/_ci_stage.html.haml
View file @
504a1fac
-
statuses
=
ci_commit
.
statuses
.
where
(
stage:
stage
).
to_a
-
latest
=
statuses
.
latest
-
retried
=
statuses
.
select
(
&
:retried?
)
-
retried
=
statuses
.
where
.
not
(
id:
latest
)
-
latest
=
statuses
-
retried
%tr
%tr
%th
{
colspan:
10
}
%th
{
colspan:
10
}
%strong
%strong
-
status
=
latest
.
status
%span
{
class:
"ci-status-link ci-status-icon-#{status}"
}
%span
{
class:
"ci-status-link ci-status-icon-#{status}"
}
=
ci_icon_for_status
(
status
)
=
ci_icon_for_status
(
status
)
=
stage
.
titleize
.
pluralize
=
stage
.
titleize
.
pluralize
=
render
latest
,
coverage:
@project
.
build_coverage_enabled?
,
tage:
false
,
ref:
false
,
allow_retry:
true
=
render
latest
.
ordered
,
coverage:
@project
.
build_coverage_enabled?
,
tage:
false
,
ref:
false
,
allow_retry:
true
=
render
retried
,
coverage:
@project
.
build_coverage_enabled?
,
stage:
false
,
ref:
false
,
retried:
true
=
render
retried
.
ordered
,
coverage:
@project
.
build_coverage_enabled?
,
stage:
false
,
ref:
false
,
retried:
true
%tr
%tr
%td
{
colspan:
10
}
%td
{
colspan:
10
}
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