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
Tatuya Kamada
gitlab-ce
Commits
ca6da6ea
Commit
ca6da6ea
authored
Nov 15, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed pipeline column and fixed permissions for builds in events controller
parent
73e9ec63
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
11 deletions
+14
-11
app/controllers/projects/cycle_analytics/events_controller.rb
...controllers/projects/cycle_analytics/events_controller.rb
+4
-3
app/models/merge_request/metrics.rb
app/models/merge_request/metrics.rb
+1
-1
app/workers/pipeline_metrics_worker.rb
app/workers/pipeline_metrics_worker.rb
+2
-2
db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb
...0161020083353_add_pipeline_id_to_merge_request_metrics.rb
+3
-1
db/schema.rb
db/schema.rb
+3
-3
lib/gitlab/cycle_analytics/events_fetcher.rb
lib/gitlab/cycle_analytics/events_fetcher.rb
+1
-1
No files found.
app/controllers/projects/cycle_analytics/events_controller.rb
View file @
ca6da6ea
...
@@ -2,6 +2,7 @@ class Projects::CycleAnalytics::EventsController < Projects::ApplicationControll
...
@@ -2,6 +2,7 @@ class Projects::CycleAnalytics::EventsController < Projects::ApplicationControll
include
CycleAnalyticsParams
include
CycleAnalyticsParams
before_action
:authorize_read_cycle_analytics!
before_action
:authorize_read_cycle_analytics!
before_action
:authorize_read_builds!
,
only:
[
:test
,
:staging
]
def
issue
def
issue
render_events
(
events
.
issue_events
)
render_events
(
events
.
issue_events
)
...
@@ -16,7 +17,7 @@ class Projects::CycleAnalytics::EventsController < Projects::ApplicationControll
...
@@ -16,7 +17,7 @@ class Projects::CycleAnalytics::EventsController < Projects::ApplicationControll
end
end
def
test
def
test
@opts
=
{
from:
start_date
(
events_params
),
branch:
events_params
[
:branch_name
]
}
@opt
ion
s
=
{
from:
start_date
(
events_params
),
branch:
events_params
[
:branch_name
]
}
render_events
(
events
.
test_events
)
render_events
(
events
.
test_events
)
end
end
...
@@ -47,12 +48,12 @@ class Projects::CycleAnalytics::EventsController < Projects::ApplicationControll
...
@@ -47,12 +48,12 @@ class Projects::CycleAnalytics::EventsController < Projects::ApplicationControll
end
end
def
options
def
options
@opts
||=
{
from:
start_date
(
events_params
)
}
@opt
ion
s
||=
{
from:
start_date
(
events_params
)
}
end
end
def
events_params
def
events_params
return
{}
unless
params
[
:events
].
present?
return
{}
unless
params
[
:events
].
present?
{
start_date:
params
[
:events
][
:start_date
],
branch_name:
params
[
:events
][
:branch_name
]
}
params
[
:events
].
slice
(
:start_date
,
:branch_name
)
end
end
end
end
app/models/merge_request/metrics.rb
View file @
ca6da6ea
class
MergeRequest::Metrics
<
ActiveRecord
::
Base
class
MergeRequest::Metrics
<
ActiveRecord
::
Base
belongs_to
:merge_request
belongs_to
:merge_request
belongs_to
:pipeline
,
class_name:
'Ci::Pipeline'
,
foreign_key: :
ci_commit
_id
belongs_to
:pipeline
,
class_name:
'Ci::Pipeline'
,
foreign_key: :
pipeline
_id
def
record!
def
record!
if
merge_request
.
merged?
&&
self
.
merged_at
.
blank?
if
merge_request
.
merged?
&&
self
.
merged_at
.
blank?
...
...
app/workers/pipeline_metrics_worker.rb
View file @
ca6da6ea
...
@@ -12,11 +12,11 @@ class PipelineMetricsWorker
...
@@ -12,11 +12,11 @@ class PipelineMetricsWorker
private
private
def
update_metrics_for_active_pipeline
(
pipeline
)
def
update_metrics_for_active_pipeline
(
pipeline
)
metrics
(
pipeline
).
update_all
(
latest_build_started_at:
pipeline
.
started_at
,
latest_build_finished_at:
nil
,
ci_commit
_id:
pipeline
.
id
)
metrics
(
pipeline
).
update_all
(
latest_build_started_at:
pipeline
.
started_at
,
latest_build_finished_at:
nil
,
pipeline
_id:
pipeline
.
id
)
end
end
def
update_metrics_for_succeeded_pipeline
(
pipeline
)
def
update_metrics_for_succeeded_pipeline
(
pipeline
)
metrics
(
pipeline
).
update_all
(
latest_build_started_at:
pipeline
.
started_at
,
latest_build_finished_at:
pipeline
.
finished_at
,
ci_commit
_id:
pipeline
.
id
)
metrics
(
pipeline
).
update_all
(
latest_build_started_at:
pipeline
.
started_at
,
latest_build_finished_at:
pipeline
.
finished_at
,
pipeline
_id:
pipeline
.
id
)
end
end
def
metrics
(
pipeline
)
def
metrics
(
pipeline
)
...
...
db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb
View file @
ca6da6ea
...
@@ -24,6 +24,8 @@ class AddPipelineIdToMergeRequestMetrics < ActiveRecord::Migration
...
@@ -24,6 +24,8 @@ class AddPipelineIdToMergeRequestMetrics < ActiveRecord::Migration
# disable_ddl_transaction!
# disable_ddl_transaction!
def
change
def
change
add_reference
:merge_request_metrics
,
:ci_commit
,
index:
true
,
foreign_key:
{
on_delete: :cascade
}
add_column
:merge_request_metrics
,
:pipeline_id
,
:integer
add_index
:merge_request_metrics
,
:pipeline_id
add_foreign_key
:merge_request_metrics
,
:ci_commits
,
column: :pipeline_id
,
on_delete: :cascade
end
end
end
end
db/schema.rb
View file @
ca6da6ea
...
@@ -634,12 +634,12 @@ ActiveRecord::Schema.define(version: 20161109150329) do
...
@@ -634,12 +634,12 @@ ActiveRecord::Schema.define(version: 20161109150329) do
t
.
datetime
"merged_at"
t
.
datetime
"merged_at"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
integer
"
ci_commit
_id"
t
.
integer
"
pipeline
_id"
end
end
add_index
"merge_request_metrics"
,
[
"ci_commit_id"
],
name:
"index_merge_request_metrics_on_ci_commit_id"
,
using: :btree
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"
,
[
"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
add_index
"merge_request_metrics"
,
[
"merge_request_id"
],
name:
"index_merge_request_metrics"
,
using: :btree
add_index
"merge_request_metrics"
,
[
"pipeline_id"
],
name:
"index_merge_request_metrics_on_pipeline_id"
,
using: :btree
create_table
"merge_requests"
,
force: :cascade
do
|
t
|
create_table
"merge_requests"
,
force: :cascade
do
|
t
|
t
.
string
"target_branch"
,
null:
false
t
.
string
"target_branch"
,
null:
false
...
@@ -1246,7 +1246,7 @@ ActiveRecord::Schema.define(version: 20161109150329) do
...
@@ -1246,7 +1246,7 @@ ActiveRecord::Schema.define(version: 20161109150329) do
add_foreign_key
"labels"
,
"namespaces"
,
column:
"group_id"
,
on_delete: :cascade
add_foreign_key
"labels"
,
"namespaces"
,
column:
"group_id"
,
on_delete: :cascade
add_foreign_key
"lists"
,
"boards"
add_foreign_key
"lists"
,
"boards"
add_foreign_key
"lists"
,
"labels"
add_foreign_key
"lists"
,
"labels"
add_foreign_key
"merge_request_metrics"
,
"ci_commits"
,
on_delete: :cascade
add_foreign_key
"merge_request_metrics"
,
"ci_commits"
,
column:
"pipeline_id"
,
on_delete: :cascade
add_foreign_key
"merge_request_metrics"
,
"merge_requests"
,
on_delete: :cascade
add_foreign_key
"merge_request_metrics"
,
"merge_requests"
,
on_delete: :cascade
add_foreign_key
"merge_requests_closing_issues"
,
"issues"
,
on_delete: :cascade
add_foreign_key
"merge_requests_closing_issues"
,
"issues"
,
on_delete: :cascade
add_foreign_key
"merge_requests_closing_issues"
,
"merge_requests"
,
on_delete: :cascade
add_foreign_key
"merge_requests_closing_issues"
,
"merge_requests"
,
on_delete: :cascade
...
...
lib/gitlab/cycle_analytics/events_fetcher.rb
View file @
ca6da6ea
...
@@ -20,7 +20,7 @@ module Gitlab
...
@@ -20,7 +20,7 @@ module Gitlab
end
end
def
test_custom_query
(
base_query
)
def
test_custom_query
(
base_query
)
base_query
.
join
(
build_table
).
on
(
mr_metrics_table
[
:
ci_commit
_id
].
eq
(
build_table
[
:commit_id
]))
base_query
.
join
(
build_table
).
on
(
mr_metrics_table
[
:
pipeline
_id
].
eq
(
build_table
[
:commit_id
]))
end
end
alias_method
:staging_custom_query
,
:test_custom_query
alias_method
:staging_custom_query
,
:test_custom_query
...
...
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