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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
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
alias_attribute
:author
,
:user
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
])
}
state_machine
:status
,
initial: :pending
do
...
...
@@ -91,13 +91,15 @@ class CommitStatus < ActiveRecord::Base
end
def
self
.
stages
order_by
=
'max(stage_idx)'
CommitStatus
.
where
(
id:
all
).
group
(
'stage'
).
order
(
order_by
).
pluck
(
:stage
,
order_by
).
map
(
&
:first
).
compact
# We group by stage name, but order stages by their's index
unscoped
.
from
(
all
,
:sg
).
group
(
'stage'
).
order
(
'max(stage_idx)'
,
'stage'
).
pluck
(
'sg.stage'
)
end
def
self
.
stages_status
all
.
stages
.
inject
({})
do
|
h
,
stage
|
h
[
stage
]
=
all
.
where
(
stage:
stage
).
status
# We execute subquery for each of the stages which calculates an 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
end
end
...
...
app/views/projects/commit/_ci_commit.html.haml
View file @
504a1fac
...
...
@@ -36,6 +36,5 @@
.table-holder
%table
.table.builds
-
stages
=
ci_commit
.
statuses
.
latest
.
stages_status
-
stages
.
each
do
|
stage
,
status
|
=
render
'ci_stage'
,
stage:
stage
,
status:
status
-
ci_commit
.
statuses
.
stages
.
each
do
|
stage
|
=
render
'projects/commit/ci_stage'
,
stage:
stage
,
statuses:
ci_commit
.
statuses
.
where
(
stage:
stage
)
app/views/projects/commit/_ci_stage.html.haml
View file @
504a1fac
-
statuses
=
ci_commit
.
statuses
.
where
(
stage:
stage
).
to_a
-
retried
=
statuses
.
select
(
&
:retried?
)
-
latest
=
statuses
-
retried
-
latest
=
statuses
.
latest
-
retried
=
statuses
.
where
.
not
(
id:
latest
)
%tr
%th
{
colspan:
10
}
%strong
-
status
=
latest
.
status
%span
{
class:
"ci-status-link ci-status-icon-#{status}"
}
=
ci_icon_for_status
(
status
)
=
stage
.
titleize
.
pluralize
=
render
latest
,
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
latest
.
ordered
,
coverage:
@project
.
build_coverage_enabled?
,
tage:
false
,
ref:
false
,
allow_retry:
true
=
render
retried
.
ordered
,
coverage:
@project
.
build_coverage_enabled?
,
stage:
false
,
ref:
false
,
retried:
true
%tr
%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