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
caf6b991
Commit
caf6b991
authored
Jun 15, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check warnings when building compound status SQL query
parent
51ce9a6c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
17 deletions
+14
-17
app/models/commit_status.rb
app/models/commit_status.rb
+0
-6
app/models/concerns/has_status.rb
app/models/concerns/has_status.rb
+13
-10
spec/models/commit_status_spec.rb
spec/models/commit_status_spec.rb
+1
-1
No files found.
app/models/commit_status.rb
View file @
caf6b991
...
@@ -103,12 +103,6 @@ class CommitStatus < ActiveRecord::Base
...
@@ -103,12 +103,6 @@ class CommitStatus < ActiveRecord::Base
end
end
end
end
def
self
.
status
super
.
tap
do
|
status
|
return
'success'
if
status
==
'skipped'
&&
all
.
failed_but_allowed
.
any?
end
end
def
locking_enabled?
def
locking_enabled?
status_changed?
status_changed?
end
end
...
...
app/models/concerns/has_status.rb
View file @
caf6b991
...
@@ -11,18 +11,21 @@ module HasStatus
...
@@ -11,18 +11,21 @@ module HasStatus
class_methods
do
class_methods
do
def
status_sql
def
status_sql
scope
=
respond_to?
(
:exclude_ignored
)
?
exclude_ignored
:
all
scope_relevant
=
respond_to?
(
:exclude_ignored
)
?
exclude_ignored
:
all
scope_warnings
=
respond_to?
(
:failed_but_allowed
)
?
failed_but_allowed
:
none
builds
=
scope
.
select
(
'count(*)'
).
to_sql
created
=
scope
.
created
.
select
(
'count(*)'
).
to_sql
builds
=
scope_relevant
.
select
(
'count(*)'
).
to_sql
success
=
scope
.
success
.
select
(
'count(*)'
).
to_sql
created
=
scope_relevant
.
created
.
select
(
'count(*)'
).
to_sql
manual
=
scope
.
manual
.
select
(
'count(*)'
).
to_sql
success
=
scope_relevant
.
success
.
select
(
'count(*)'
).
to_sql
pending
=
scope
.
pending
.
select
(
'count(*)'
).
to_sql
manual
=
scope_relevant
.
manual
.
select
(
'count(*)'
).
to_sql
running
=
scope
.
running
.
select
(
'count(*)'
).
to_sql
pending
=
scope_relevant
.
pending
.
select
(
'count(*)'
).
to_sql
skipped
=
scope
.
skipped
.
select
(
'count(*)'
).
to_sql
running
=
scope_relevant
.
running
.
select
(
'count(*)'
).
to_sql
canceled
=
scope
.
canceled
.
select
(
'count(*)'
).
to_sql
skipped
=
scope_relevant
.
skipped
.
select
(
'count(*)'
).
to_sql
canceled
=
scope_relevant
.
canceled
.
select
(
'count(*)'
).
to_sql
warnings
=
scope_warnings
.
select
(
'count(*) > 0'
).
to_sql
.
presence
||
'false'
"(CASE
"(CASE
WHEN (
#{
builds
}
)=(
#{
skipped
}
) AND (
#{
warnings
}
) THEN 'success'
WHEN (
#{
builds
}
)=(
#{
skipped
}
) THEN 'skipped'
WHEN (
#{
builds
}
)=(
#{
skipped
}
) THEN 'skipped'
WHEN (
#{
builds
}
)=(
#{
success
}
) THEN 'success'
WHEN (
#{
builds
}
)=(
#{
success
}
) THEN 'success'
WHEN (
#{
builds
}
)=(
#{
created
}
) THEN 'created'
WHEN (
#{
builds
}
)=(
#{
created
}
) THEN 'created'
...
...
spec/models/commit_status_spec.rb
View file @
caf6b991
...
@@ -309,7 +309,7 @@ describe CommitStatus, :models do
...
@@ -309,7 +309,7 @@ describe CommitStatus, :models do
context
'when using a scope to select latest statuses'
do
context
'when using a scope to select latest statuses'
do
before
do
before
do
create_status
(
name:
'test'
,
status:
'failed'
)
create_status
(
name:
'test'
,
retried:
true
,
status:
'failed'
)
create_status
(
allow_failure:
true
,
name:
'test'
,
status:
'failed'
)
create_status
(
allow_failure:
true
,
name:
'test'
,
status:
'failed'
)
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