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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
c6532ee3
Commit
c6532ee3
authored
Nov 07, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored light url builder
parent
fb424b3d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
29 deletions
+29
-29
lib/gitlab/cycle_analytics/query_config.rb
lib/gitlab/cycle_analytics/query_config.rb
+14
-7
lib/gitlab/light_url_builder.rb
lib/gitlab/light_url_builder.rb
+15
-22
No files found.
lib/gitlab/cycle_analytics/query_config.rb
View file @
c6532ee3
...
@@ -16,7 +16,8 @@ module Gitlab
...
@@ -16,7 +16,8 @@ module Gitlab
end
end
def
issue
def
issue
{
start_time_attrs:
issue_table
[
:created_at
],
{
start_time_attrs:
issue_table
[
:created_at
],
end_time_attrs:
[
issue_metrics_table
[
:first_associated_with_milestone_at
],
end_time_attrs:
[
issue_metrics_table
[
:first_associated_with_milestone_at
],
issue_metrics_table
[
:first_added_to_board_at
]],
issue_metrics_table
[
:first_added_to_board_at
]],
projections:
[
issue_table
[
:title
],
projections:
[
issue_table
[
:title
],
...
@@ -30,7 +31,8 @@ module Gitlab
...
@@ -30,7 +31,8 @@ module Gitlab
end
end
def
plan
def
plan
{
start_time_attrs:
issue_metrics_table
[
:first_associated_with_milestone_at
],
{
start_time_attrs:
issue_metrics_table
[
:first_associated_with_milestone_at
],
end_time_attrs:
[
issue_metrics_table
[
:first_added_to_board_at
],
end_time_attrs:
[
issue_metrics_table
[
:first_added_to_board_at
],
issue_metrics_table
[
:first_mentioned_in_commit_at
]],
issue_metrics_table
[
:first_mentioned_in_commit_at
]],
projections:
[
mr_diff_table
[
:st_commits
].
as
(
'commits'
)]
projections:
[
mr_diff_table
[
:st_commits
].
as
(
'commits'
)]
...
@@ -38,7 +40,8 @@ module Gitlab
...
@@ -38,7 +40,8 @@ module Gitlab
end
end
def
code
def
code
{
start_time_attrs:
issue_metrics_table
[
:first_mentioned_in_commit_at
],
{
start_time_attrs:
issue_metrics_table
[
:first_mentioned_in_commit_at
],
end_time_attrs:
mr_table
[
:created_at
],
end_time_attrs:
mr_table
[
:created_at
],
projections:
[
mr_table
[
:title
],
projections:
[
mr_table
[
:title
],
mr_table
[
:iid
],
mr_table
[
:iid
],
...
@@ -53,7 +56,8 @@ module Gitlab
...
@@ -53,7 +56,8 @@ module Gitlab
end
end
def
test
def
test
{
start_time_attrs:
mr_metrics_table
[
:latest_build_started_at
],
{
start_time_attrs:
mr_metrics_table
[
:latest_build_started_at
],
end_time_attrs:
mr_metrics_table
[
:latest_build_finished_at
],
end_time_attrs:
mr_metrics_table
[
:latest_build_finished_at
],
projections:
[
build_table
[
:id
]],
projections:
[
build_table
[
:id
]],
order:
build_table
[
:created_at
]
order:
build_table
[
:created_at
]
...
@@ -61,7 +65,8 @@ module Gitlab
...
@@ -61,7 +65,8 @@ module Gitlab
end
end
def
review
def
review
{
start_time_attrs:
mr_table
[
:created_at
],
{
start_time_attrs:
mr_table
[
:created_at
],
end_time_attrs:
mr_metrics_table
[
:merged_at
],
end_time_attrs:
mr_metrics_table
[
:merged_at
],
projections:
[
mr_table
[
:title
],
projections:
[
mr_table
[
:title
],
mr_table
[
:iid
],
mr_table
[
:iid
],
...
@@ -75,7 +80,8 @@ module Gitlab
...
@@ -75,7 +80,8 @@ module Gitlab
end
end
def
staging
def
staging
{
start_time_attrs:
mr_metrics_table
[
:merged_at
],
{
start_time_attrs:
mr_metrics_table
[
:merged_at
],
end_time_attrs:
mr_metrics_table
[
:first_deployed_to_production_at
],
end_time_attrs:
mr_metrics_table
[
:first_deployed_to_production_at
],
projections:
[
build_table
[
:id
]],
projections:
[
build_table
[
:id
]],
order:
build_table
[
:created_at
]
order:
build_table
[
:created_at
]
...
@@ -83,7 +89,8 @@ module Gitlab
...
@@ -83,7 +89,8 @@ module Gitlab
end
end
def
production
def
production
{
start_time_attrs:
issue_table
[
:created_at
],
{
start_time_attrs:
issue_table
[
:created_at
],
end_time_attrs:
mr_metrics_table
[
:first_deployed_to_production_at
],
end_time_attrs:
mr_metrics_table
[
:first_deployed_to_production_at
],
projections:
[
issue_table
[
:title
],
projections:
[
issue_table
[
:title
],
issue_table
[
:iid
],
issue_table
[
:iid
],
...
...
lib/gitlab/light_url_builder.rb
View file @
c6532ee3
module
Gitlab
module
Gitlab
# Similar to UrlBuilder, but using IDs to avoid querying the DB for objects
# Useful for using in conjunction with Arel queries.
class
LightUrlBuilder
class
LightUrlBuilder
include
Gitlab
::
Routing
.
url_helpers
include
Gitlab
::
Routing
.
url_helpers
include
GitlabRoutingHelper
include
GitlabRoutingHelper
...
@@ -16,28 +18,11 @@ module Gitlab
...
@@ -16,28 +18,11 @@ module Gitlab
end
end
def
url
def
url
# TODO refactor this
url_method
=
"
#{
@entity
}
_url"
case
@entity
raise
NotImplementedError
.
new
(
"No Light URL builder defined for
#{
@entity
.
to_s
}
"
)
unless
respond_to?
(
url_method
)
when
:issue
issue_url
when
:user
user_url
(
@id
)
when
:user_avatar
user_avatar_url
when
:commit
commit_url
when
:merge_request
mr_url
when
:build
namespace_project_build_url
(
@project
.
namespace
,
@project
,
@id
)
when
:branch
branch_url
else
raise
NotImplementedError
.
new
(
"No URL builder defined for
#{
object
.
class
}
"
)
end
end
private
public_send
(
url_method
)
end
def
issue_url
def
issue_url
namespace_project_issue_url
({
namespace_project_issue_url
({
...
@@ -59,7 +44,7 @@ module Gitlab
...
@@ -59,7 +44,7 @@ module Gitlab
}.
merge!
(
@opts
))
}.
merge!
(
@opts
))
end
end
def
m
r
_url
def
m
erge_request
_url
namespace_project_merge_request_url
({
namespace_project_merge_request_url
({
namespace_id:
@project
.
namespace
,
namespace_id:
@project
.
namespace
,
project_id:
@project
,
project_id:
@project
,
...
@@ -70,5 +55,13 @@ module Gitlab
...
@@ -70,5 +55,13 @@ module Gitlab
def
branch_url
def
branch_url
"
#{
project_url
(
@project
)
}
/commits/
#{
@id
}
"
"
#{
project_url
(
@project
)
}
/commits/
#{
@id
}
"
end
end
def
user_url
Gitlab
::
Routing
.
url_helpers
.
user_url
(
@id
)
end
def
build_url
namespace_project_build_url
(
@project
.
namespace
,
@project
,
@id
)
end
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