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
Boxiang Sun
gitlab-ce
Commits
316ccb64
Commit
316ccb64
authored
Nov 09, 2017
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add `active` scope only once, inline methods
parent
d4bda7c1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
13 deletions
+2
-13
app/models/project.rb
app/models/project.rb
+2
-12
spec/models/project_spec.rb
spec/models/project_spec.rb
+0
-1
No files found.
app/models/project.rb
View file @
316ccb64
...
@@ -225,8 +225,6 @@ class Project < ActiveRecord::Base
...
@@ -225,8 +225,6 @@ class Project < ActiveRecord::Base
has_many
:project_deploy_tokens
has_many
:project_deploy_tokens
has_many
:deploy_tokens
,
through: :project_deploy_tokens
has_many
:deploy_tokens
,
through: :project_deploy_tokens
has_many
:active_runners
,
->
{
active
},
through: :runner_projects
,
source: :runner
,
class_name:
'Ci::Runner'
has_one
:auto_devops
,
class_name:
'ProjectAutoDevops'
has_one
:auto_devops
,
class_name:
'ProjectAutoDevops'
has_many
:custom_attributes
,
class_name:
'ProjectCustomAttribute'
has_many
:custom_attributes
,
class_name:
'ProjectCustomAttribute'
...
@@ -1311,21 +1309,13 @@ class Project < ActiveRecord::Base
...
@@ -1311,21 +1309,13 @@ class Project < ActiveRecord::Base
@shared_runners
||=
shared_runners_enabled?
?
Ci
::
Runner
.
shared
:
Ci
::
Runner
.
none
@shared_runners
||=
shared_runners_enabled?
?
Ci
::
Runner
.
shared
:
Ci
::
Runner
.
none
end
end
def
active_shared_runners
@active_shared_runners
||=
shared_runners
.
active
end
def
group_runners
def
group_runners
@group_runners
||=
group_runners_enabled?
?
Ci
::
Runner
.
belonging_to_group
(
self
.
id
)
:
Ci
::
Runner
.
none
@group_runners
||=
group_runners_enabled?
?
Ci
::
Runner
.
belonging_to_group
(
self
.
id
)
:
Ci
::
Runner
.
none
end
end
def
active_group_runners
@active_group_runners
||=
group_runners
.
active
end
def
any_runners?
(
&
block
)
def
any_runners?
(
&
block
)
union
=
Gitlab
::
SQL
::
Union
.
new
([
active_runners
,
active_shared_runners
,
active_
group_runners
])
union
=
Gitlab
::
SQL
::
Union
.
new
([
runners
,
shared_runners
,
group_runners
])
runners
=
Ci
::
Runner
.
from
(
"(
#{
union
.
to_sql
}
) ci_runners"
)
runners
=
Ci
::
Runner
.
from
(
"(
#{
union
.
to_sql
}
) ci_runners"
)
.
active
runners
.
any?
(
&
block
)
runners
.
any?
(
&
block
)
end
end
...
...
spec/models/project_spec.rb
View file @
316ccb64
...
@@ -63,7 +63,6 @@ describe Project do
...
@@ -63,7 +63,6 @@ describe Project do
it
{
is_expected
.
to
have_many
(
:build_trace_section_names
)}
it
{
is_expected
.
to
have_many
(
:build_trace_section_names
)}
it
{
is_expected
.
to
have_many
(
:runner_projects
)
}
it
{
is_expected
.
to
have_many
(
:runner_projects
)
}
it
{
is_expected
.
to
have_many
(
:runners
)
}
it
{
is_expected
.
to
have_many
(
:runners
)
}
it
{
is_expected
.
to
have_many
(
:active_runners
)
}
it
{
is_expected
.
to
have_many
(
:variables
)
}
it
{
is_expected
.
to
have_many
(
:variables
)
}
it
{
is_expected
.
to
have_many
(
:triggers
)
}
it
{
is_expected
.
to
have_many
(
:triggers
)
}
it
{
is_expected
.
to
have_many
(
:pages_domains
)
}
it
{
is_expected
.
to
have_many
(
:pages_domains
)
}
...
...
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