BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
7 deletions
+15
-7
environment.rb
app/models/environment.rb
+1
-1
project.rb
app/models/project.rb
+12
-5
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