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
Léo-Paul Géneau
gitlab-ce
Commits
16fc61d6
Commit
16fc61d6
authored
Nov 07, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rever add action follow up 1
parent
9c811566
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
58 additions
and
29 deletions
+58
-29
app/finders/environments_finder.rb
app/finders/environments_finder.rb
+1
-1
app/models/deployment.rb
app/models/deployment.rb
+1
-1
app/models/environment.rb
app/models/environment.rb
+1
-1
app/models/environment_status.rb
app/models/environment_status.rb
+2
-0
db/schema.rb
db/schema.rb
+32
-1
lib/gitlab/cycle_analytics/summary/deploy.rb
lib/gitlab/cycle_analytics/summary/deploy.rb
+1
-1
spec/models/environment_spec.rb
spec/models/environment_spec.rb
+20
-24
No files found.
app/finders/environments_finder.rb
View file @
16fc61d6
...
...
@@ -9,7 +9,7 @@ class EnvironmentsFinder
# rubocop: disable CodeReuse/ActiveRecord
def
execute
deployments
=
project
.
deployments
.
success
deployments
=
project
.
deployments
deployments
=
if
ref
deployments_query
=
params
[
:with_tags
]
?
'ref = :ref OR tag IS TRUE'
:
'ref = :ref'
...
...
app/models/deployment.rb
View file @
16fc61d6
...
...
@@ -132,7 +132,7 @@ class Deployment < ActiveRecord::Base
def
previous_deployment
@previous_deployment
||=
project
.
deployments
.
success
.
joins
(
:environment
)
project
.
deployments
.
joins
(
:environment
)
.
where
(
environments:
{
name:
self
.
environment
.
name
},
ref:
self
.
ref
)
.
where
.
not
(
id:
self
.
id
)
.
take
...
...
app/models/environment.rb
View file @
16fc61d6
...
...
@@ -96,7 +96,7 @@ class Environment < ActiveRecord::Base
end
def
last_deployed_at
last_deployment
.
try
(
:
finish
ed_at
)
last_deployment
.
try
(
:
creat
ed_at
)
end
def
update_merge_request_metrics?
...
...
app/models/environment_status.rb
View file @
16fc61d6
...
...
@@ -47,6 +47,8 @@ class EnvironmentStatus
# Since frontend has not supported all statuses yet, BE has to
# proxy some status to a supported status.
def
status
return
unless
deployment
case
deployment
.
status
when
'created'
'running'
...
...
db/schema.rb
View file @
16fc61d6
...
...
@@ -927,6 +927,35 @@ ActiveRecord::Schema.define(version: 20181106135939) do
add_index
"forked_project_links"
,
[
"forked_to_project_id"
],
name:
"index_forked_project_links_on_forked_to_project_id"
,
unique:
true
,
using: :btree
create_table
"gcp_clusters"
,
force: :cascade
do
|
t
|
t
.
integer
"project_id"
,
null:
false
t
.
integer
"user_id"
t
.
integer
"service_id"
t
.
integer
"status"
t
.
integer
"gcp_cluster_size"
,
null:
false
t
.
datetime_with_timezone
"created_at"
,
null:
false
t
.
datetime_with_timezone
"updated_at"
,
null:
false
t
.
boolean
"enabled"
,
default:
true
t
.
text
"status_reason"
t
.
string
"project_namespace"
t
.
string
"endpoint"
t
.
text
"ca_cert"
t
.
text
"encrypted_kubernetes_token"
t
.
string
"encrypted_kubernetes_token_iv"
t
.
string
"username"
t
.
text
"encrypted_password"
t
.
string
"encrypted_password_iv"
t
.
string
"gcp_project_id"
,
null:
false
t
.
string
"gcp_cluster_zone"
,
null:
false
t
.
string
"gcp_cluster_name"
,
null:
false
t
.
string
"gcp_machine_type"
t
.
string
"gcp_operation_id"
t
.
text
"encrypted_gcp_token"
t
.
string
"encrypted_gcp_token_iv"
end
add_index
"gcp_clusters"
,
[
"project_id"
],
name:
"index_gcp_clusters_on_project_id"
,
unique:
true
,
using: :btree
create_table
"gpg_key_subkeys"
,
force: :cascade
do
|
t
|
t
.
integer
"gpg_key_id"
,
null:
false
t
.
binary
"keyid"
...
...
@@ -1827,7 +1856,6 @@ ActiveRecord::Schema.define(version: 20181106135939) do
end
add_index
"redirect_routes"
,
[
"path"
],
name:
"index_redirect_routes_on_path"
,
unique:
true
,
using: :btree
add_index
"redirect_routes"
,
[
"path"
],
name:
"index_redirect_routes_on_path_text_pattern_ops"
,
using: :btree
,
opclasses:
{
"path"
=>
"varchar_pattern_ops"
}
add_index
"redirect_routes"
,
[
"source_type"
,
"source_id"
],
name:
"index_redirect_routes_on_source_type_and_source_id"
,
using: :btree
create_table
"releases"
,
force: :cascade
do
|
t
|
...
...
@@ -2411,6 +2439,9 @@ ActiveRecord::Schema.define(version: 20181106135939) do
add_foreign_key
"fork_network_members"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"fork_networks"
,
"projects"
,
column:
"root_project_id"
,
name:
"fk_e7b436b2b5"
,
on_delete: :nullify
add_foreign_key
"forked_project_links"
,
"projects"
,
column:
"forked_to_project_id"
,
name:
"fk_434510edb0"
,
on_delete: :cascade
add_foreign_key
"gcp_clusters"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"gcp_clusters"
,
"services"
,
on_delete: :nullify
add_foreign_key
"gcp_clusters"
,
"users"
,
on_delete: :nullify
add_foreign_key
"gpg_key_subkeys"
,
"gpg_keys"
,
on_delete: :cascade
add_foreign_key
"gpg_keys"
,
"users"
,
on_delete: :cascade
add_foreign_key
"gpg_signatures"
,
"gpg_key_subkeys"
,
on_delete: :nullify
...
...
lib/gitlab/cycle_analytics/summary/deploy.rb
View file @
16fc61d6
...
...
@@ -7,7 +7,7 @@ module Gitlab
end
def
value
@value
||=
@project
.
deployments
.
success
.
where
(
"created_at > ?"
,
@from
).
count
@value
||=
@project
.
deployments
.
where
(
"created_at > ?"
,
@from
).
count
end
end
end
...
...
spec/models/environment_spec.rb
View file @
16fc61d6
...
...
@@ -72,30 +72,6 @@ describe Environment do
end
end
describe
'#last_deployed_at'
do
subject
{
environment
.
last_deployed_at
}
let
(
:environment
)
{
create
(
:environment
)
}
context
'when the latest deployment is successful'
do
let!
(
:deployment
)
{
create
(
:deployment
,
:success
,
environment:
environment
)
}
it
{
expect
(
subject
).
to
be_within
(
1
.
second
).
of
(
deployment
.
finished_at
)
}
end
context
'when the latest deployment failed'
do
let!
(
:deployment
)
{
create
(
:deployment
,
:failed
,
environment:
environment
)
}
it
{
is_expected
.
to
be_nil
}
end
context
'when the latest deployment is running'
do
let!
(
:deployment
)
{
create
(
:deployment
,
:running
,
environment:
environment
)
}
it
{
is_expected
.
to
be_nil
}
end
end
describe
'#folder_name'
do
context
'when it is inside a folder'
do
subject
(
:environment
)
do
...
...
@@ -177,6 +153,26 @@ describe Environment do
end
end
describe
'#first_deployment_for'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let!
(
:deployment
)
{
create
(
:deployment
,
:succeed
,
environment:
environment
,
ref:
commit
.
parent
.
id
)
}
let!
(
:deployment1
)
{
create
(
:deployment
,
:succeed
,
environment:
environment
,
ref:
commit
.
id
)
}
let
(
:head_commit
)
{
project
.
commit
}
let
(
:commit
)
{
project
.
commit
.
parent
}
it
'returns deployment id for the environment'
do
expect
(
environment
.
first_deployment_for
(
commit
.
id
)).
to
eq
deployment1
end
it
'return nil when no deployment is found'
do
expect
(
environment
.
first_deployment_for
(
head_commit
.
id
)).
to
eq
nil
end
it
'returns a UTF-8 ref'
do
expect
(
environment
.
first_deployment_for
(
commit
.
id
).
ref
).
to
be_utf8
end
end
describe
'#environment_type'
do
subject
{
environment
.
environment_type
}
...
...
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