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
e49229aa
Commit
e49229aa
authored
Nov 16, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor methods for environments in project model
parent
c95b88e6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
7 deletions
+15
-7
app/models/environment.rb
app/models/environment.rb
+1
-1
app/models/project.rb
app/models/project.rb
+12
-5
app/services/ci/stop_environments_service.rb
app/services/ci/stop_environments_service.rb
+2
-1
No files found.
app/models/environment.rb
View file @
e49229aa
...
...
@@ -37,7 +37,7 @@ class Environment < ActiveRecord::Base
state
:stopped
end
def
recently_updated_on?
(
ref
)
def
recently_updated_on
_branch
?
(
ref
)
ref
.
to_s
==
last_deployment
.
ref
end
...
...
app/models/project.rb
View file @
e49229aa
...
...
@@ -1296,12 +1296,19 @@ class Project < ActiveRecord::Base
.
group
(
:environment_id
)
.
select
(
:environment_id
)
envs
=
environments
.
available
.
where
(
id:
environment_ids
)
environments_found
=
environments
.
available
.
where
(
id:
environment_ids
).
to_a
if
commit
envs
.
select
{
|
environment
|
env
.
includes_commit?
(
commit
)
}
else
envs
.
select
{
|
environment
|
env
.
recently_updated_on?
(
ref
)
}
return
environments_found
unless
commit
environments_found
.
select
do
|
environment
|
environment
.
includes_commit?
(
commit
)
end
end
def
environments_recently_updated_on_branch
(
branch
)
environments_for
(
branch
).
select
do
|
environment
|
environment
.
recently_updated_on_branch?
(
branch
)
end
end
...
...
app/services/ci/stop_environments_service.rb
View file @
e49229aa
...
...
@@ -27,7 +27,8 @@ module Ci
end
def
environments
@environments
||=
project
.
environments_for
(
@ref
)
@environments
||=
project
.
environments_recently_updated_on_branch
(
@ref
)
end
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