Commit 35e2315a authored by Z.J. van de Weg's avatar Z.J. van de Weg

Minor style improvement

parent 4b40027b
......@@ -404,30 +404,22 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
def ci_environments_status
environments =
environments =
begin
@merge_request.environments.map do |environment|
next unless can?(current_user, :read_environment, environment)
deployment = environment.first_deployment_for(@merge_request.diff_head_commit)
environment_data = {
name: environment.name,
{
id: environment.id,
name: environment.name,
url: namespace_project_environment_path(@project.namespace, @project, environment),
external_url: environment.external_url,
deployed_at: deployment ? deployment.created_at : nil
external_url_formatted: environment.formatted_external_url,
deployed_at: deployment.try(:created_at),
deployed_at_formatted: deployment.try(:formatted_deployment_time)
}
if environment_data[:external_url]
environment_data[:external_url_formatted] = environment_data[:external_url].gsub(/\A.*?:\/\//, '')
end
if environment_data[:deployed_at]
environment_data[:deployed_at_formatted] = environment_data[:deployed_at].to_time.in_time_zone.to_s(:medium)
end
environment_data
end.compact
end
......
......@@ -84,6 +84,10 @@ class Deployment < ActiveRecord::Base
take
end
def formatted_deployment_time
created_at.to_time.in_time_zone.to_s(:medium)
end
private
def ref_path
......
......@@ -53,11 +53,17 @@ class Environment < ActiveRecord::Base
return nil unless ref
deployment_id = ref.split('/').last.to_i
deployment_id = ref.split('/').last
deployments.find(deployment_id)
end
def ref_path
"refs/environments/#{Shellwords.shellescape(name)}"
end
def formatted_external_url
return nil unless external_url
external_url.gsub(/\A.*?:\/\//, '')
end
end
......@@ -446,6 +446,17 @@ ActiveRecord::Schema.define(version: 20161007133303) do
add_index "identities", ["user_id"], name: "index_identities_on_user_id", using: :btree
create_table "integrations", force: :cascade do |t|
t.integer "project_id"
t.string "name"
t.string "external_token"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "integrations", ["external_token"], name: "index_integrations_on_external_token", unique: true, using: :btree
add_index "integrations", ["project_id"], name: "index_integrations_on_project_id", using: :btree
create_table "issue_metrics", force: :cascade do |t|
t.integer "issue_id", null: false
t.datetime "first_mentioned_in_commit_at"
......@@ -613,7 +624,6 @@ ActiveRecord::Schema.define(version: 20161007133303) do
t.datetime "updated_at", null: false
end
add_index "merge_request_metrics", ["first_deployed_to_production_at"], name: "index_merge_request_metrics_on_first_deployed_to_production_at", using: :btree
add_index "merge_request_metrics", ["merge_request_id"], name: "index_merge_request_metrics", using: :btree
create_table "merge_requests", force: :cascade do |t|
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment