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
f19280fd
Commit
f19280fd
authored
Sep 03, 2020
by
lauraMon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactors finder a bit more
* Moves order_id_desc out of the Bridge and Build model and into CommitStatus
parent
58a136e2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
12 deletions
+12
-12
app/finders/ci/jobs_finder.rb
app/finders/ci/jobs_finder.rb
+10
-9
app/models/ci/bridge.rb
app/models/ci/bridge.rb
+0
-2
app/models/ci/build.rb
app/models/ci/build.rb
+0
-1
app/models/commit_status.rb
app/models/commit_status.rb
+2
-0
No files found.
app/finders/ci/jobs_finder.rb
View file @
f19280fd
...
...
@@ -15,15 +15,7 @@ module Ci
def
execute
builds
=
init_collection
.
order_id_desc
if
params
[
:scope
].
is_a?
(
Array
)
unknown
=
params
[
:scope
]
-
::
CommitStatus
::
AVAILABLE_STATUSES
raise
ArgumentError
,
'Scope contains invalid value(s)'
unless
unknown
.
empty?
builds
.
where
(
status:
params
[
:scope
])
# rubocop: disable CodeReuse/ActiveRecord
else
filter_by_scope
(
builds
)
end
filter_by_scope
(
builds
)
rescue
Gitlab
::
Access
::
AccessDeniedError
type
.
none
end
...
...
@@ -57,6 +49,8 @@ module Ci
end
def
filter_by_scope
(
builds
)
return
filter_by_statuses!
(
params
[
:scope
],
builds
)
if
params
[
:scope
].
is_a?
(
Array
)
case
params
[
:scope
]
when
'pending'
builds
.
pending
.
reverse_order
...
...
@@ -69,6 +63,13 @@ module Ci
end
end
def
filter_by_statuses!
(
statuses
,
builds
)
unknown_statuses
=
params
[
:scope
]
-
::
CommitStatus
::
AVAILABLE_STATUSES
raise
ArgumentError
,
'Scope contains invalid value(s)'
unless
unknown_statuses
.
empty?
builds
.
where
(
status:
params
[
:scope
])
# rubocop: disable CodeReuse/ActiveRecord
end
def
jobs_by_type
(
relation
,
type
)
case
type
.
name
when
::
Ci
::
Build
.
name
...
...
app/models/ci/bridge.rb
View file @
f19280fd
...
...
@@ -21,8 +21,6 @@ module Ci
validates
:ref
,
presence:
true
scope
:order_id_desc
,
->
{
order
(
'ci_builds.id DESC'
)
}
# rubocop:disable Cop/ActiveRecordSerialize
serialize
:options
serialize
:yaml_variables
,
::
Gitlab
::
Serializer
::
Ci
::
Variables
...
...
app/models/ci/build.rb
View file @
f19280fd
...
...
@@ -175,7 +175,6 @@ module Ci
end
scope
:queued_before
,
->
(
time
)
{
where
(
arel_table
[
:queued_at
].
lt
(
time
))
}
scope
:order_id_desc
,
->
{
order
(
'ci_builds.id DESC'
)
}
scope
:preload_project_and_pipeline_project
,
->
do
preload
(
Ci
::
Pipeline
::
PROJECT_ROUTE_AND_NAMESPACE_ROUTE
,
...
...
app/models/commit_status.rb
View file @
f19280fd
...
...
@@ -32,6 +32,8 @@ class CommitStatus < ApplicationRecord
where
(
allow_failure:
true
,
status:
[
:failed
,
:canceled
])
end
scope
:order_id_desc
,
->
{
order
(
'ci_builds.id DESC'
)
}
scope
:exclude_ignored
,
->
do
# We want to ignore failed but allowed to fail jobs.
#
...
...
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