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
f9fd0ff1
Commit
f9fd0ff1
authored
Oct 28, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some refactoring - used class instead of hash for the query configuration
parent
ca9ae8bf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
95 additions
and
46 deletions
+95
-46
lib/gitlab/cycle_analytics/events_fetcher.rb
lib/gitlab/cycle_analytics/events_fetcher.rb
+4
-44
lib/gitlab/cycle_analytics/events_query.rb
lib/gitlab/cycle_analytics/events_query.rb
+2
-2
lib/gitlab/cycle_analytics/query_config.rb
lib/gitlab/cycle_analytics/query_config.rb
+89
-0
No files found.
lib/gitlab/cycle_analytics/events_fetcher.rb
View file @
f9fd0ff1
...
...
@@ -3,48 +3,6 @@ module Gitlab
class
EventsFetcher
include
MetricsFetcher
EVENTS_CONFIG
=
{
issue:
{
start_time_attrs:
issue_table
[
:created_at
],
end_time_attrs:
[
issue_metrics_table
[
:first_associated_with_milestone_at
],
issue_metrics_table
[
:first_added_to_board_at
]],
projections:
[
issue_table
[
:title
],
issue_table
[
:iid
],
issue_table
[
:created_at
],
user_table
[
:name
],
user_table
[
:email
]]
},
plan:
{
start_time_attrs:
issue_metrics_table
[
:first_associated_with_milestone_at
],
end_time_attrs:
[
issue_metrics_table
[
:first_added_to_board_at
],
issue_metrics_table
[
:first_mentioned_in_commit_at
]],
projections:
[
mr_diff_table
[
:st_commits
].
as
(
'commits'
),
issue_metrics_table
[
:first_mentioned_in_commit_at
]]
},
code:
{
start_time_attrs:
issue_metrics_table
[
:first_mentioned_in_commit_at
],
end_time_attrs:
mr_table
[
:created_at
],
projections:
[
mr_table
[
:title
],
mr_table
[
:iid
],
mr_table
[
:created_at
],
user_table
[
:name
],
user_table
[
:email
]],
order:
mr_table
[
:created_at
]
},
test:
{
start_time_attrs:
mr_metrics_table
[
:latest_build_started_at
],
end_time_attrs:
mr_metrics_table
[
:latest_build_finished_at
],
projections:
mr_metrics_table
[
:ci_commit_id
],
order:
mr_table
[
:created_at
]
},
review:
{
start_time_attrs:
mr_table
[
:created_at
],
end_time_attrs:
mr_metrics_table
[
:merged_at
],
projections:
[
mr_table
[
:title
],
mr_table
[
:iid
],
mr_table
[
:created_at
],
user_table
[
:name
],
user_table
[
:email
]]
},
staging:
{
start_time_attrs:
mr_metrics_table
[
:merged_at
],
end_time_attrs:
mr_metrics_table
[
:first_deployed_to_production_at
],
projections:
mr_metrics_table
[
:ci_commit_id
]
},
production:
{
start_time_attrs:
issue_table
[
:created_at
],
end_time_attrs:
mr_metrics_table
[
:first_deployed_to_production_at
],
projections:
[
issue_table
[
:title
],
issue_table
[
:iid
],
issue_table
[
:created_at
],
user_table
[
:name
],
user_table
[
:email
]]
},
}.
freeze
def
initialize
(
project
:,
from
:)
@query
=
EventsQuery
.
new
(
project:
project
,
from:
from
)
end
...
...
@@ -52,11 +10,13 @@ module Gitlab
def
fetch
(
stage
:)
custom_query
=
"
#{
stage
}
_custom_query"
.
to_sym
@query
.
execute
(
stage
,
EVENTS_CONFIG
[
stage
]
)
do
|
base_query
|
public_
send
(
custom_query
,
base_query
)
if
self
.
respond_to?
(
custom_query
)
@query
.
execute
(
stage
)
do
|
base_query
|
send
(
custom_query
,
base_query
)
if
self
.
respond_to?
(
custom_query
)
end
end
private
def
issue_custom_query
(
base_query
)
base_query
.
join
(
user_table
).
on
(
issue_table
[
:author_id
].
eq
(
user_table
[
:id
]))
end
...
...
lib/gitlab/cycle_analytics/events_query.rb
View file @
f9fd0ff1
...
...
@@ -8,9 +8,9 @@ module Gitlab
@from
=
from
end
def
execute
(
stage
,
config
,
&
block
)
def
execute
(
stage
,
&
block
)
@stage
=
stage
@config
=
config
@config
=
QueryConfig
.
get
(
stage
)
query
=
build_query
(
&
block
)
ActiveRecord
::
Base
.
connection
.
execute
(
query
.
to_sql
).
to_a
...
...
lib/gitlab/cycle_analytics/query_config.rb
0 → 100644
View file @
f9fd0ff1
module
Gitlab
module
CycleAnalytics
class
QueryConfig
include
MetricsFetcher
def
self
.
get
(
*
args
)
new
(
*
args
).
get
end
def
initialize
(
stage
)
@stage
=
stage
end
def
get
send
(
@stage
).
freeze
if
self
.
respond_to?
(
@stage
)
end
private
def
issue
{
start_time_attrs:
issue_table
[
:created_at
],
end_time_attrs:
[
issue_metrics_table
[
:first_associated_with_milestone_at
],
issue_metrics_table
[
:first_added_to_board_at
]],
projections:
[
issue_table
[
:title
],
issue_table
[
:iid
],
issue_table
[
:created_at
],
user_table
[
:name
],
user_table
[
:email
]]
}
end
def
plan
{
start_time_attrs:
issue_metrics_table
[
:first_associated_with_milestone_at
],
end_time_attrs:
[
issue_metrics_table
[
:first_added_to_board_at
],
issue_metrics_table
[
:first_mentioned_in_commit_at
]],
projections:
[
mr_diff_table
[
:st_commits
].
as
(
'commits'
),
issue_metrics_table
[
:first_mentioned_in_commit_at
]]
}
end
def
code
{
start_time_attrs:
issue_metrics_table
[
:first_mentioned_in_commit_at
],
end_time_attrs:
mr_table
[
:created_at
],
projections:
[
mr_table
[
:title
],
mr_table
[
:iid
],
mr_table
[
:created_at
],
user_table
[
:name
],
user_table
[
:email
]],
order:
mr_table
[
:created_at
]
}
end
def
test
{
start_time_attrs:
mr_metrics_table
[
:latest_build_started_at
],
end_time_attrs:
mr_metrics_table
[
:latest_build_finished_at
],
projections:
mr_metrics_table
[
:ci_commit_id
],
order:
mr_table
[
:created_at
]
}
end
def
review
{
start_time_attrs:
mr_table
[
:created_at
],
end_time_attrs:
mr_metrics_table
[
:merged_at
],
projections:
[
mr_table
[
:title
],
mr_table
[
:iid
],
mr_table
[
:created_at
],
user_table
[
:name
],
user_table
[
:email
]]
}
end
def
staging
{
start_time_attrs:
mr_metrics_table
[
:merged_at
],
end_time_attrs:
mr_metrics_table
[
:first_deployed_to_production_at
],
projections:
mr_metrics_table
[
:ci_commit_id
]
}
end
def
production
{
start_time_attrs:
issue_table
[
:created_at
],
end_time_attrs:
mr_metrics_table
[
:first_deployed_to_production_at
],
projections:
[
issue_table
[
:title
],
issue_table
[
:iid
],
issue_table
[
:created_at
],
user_table
[
:name
],
user_table
[
:email
]]
}
end
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