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
98e3a1d1
Commit
98e3a1d1
authored
Jul 19, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
1adc9b64
aab38a8c
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
138 additions
and
14 deletions
+138
-14
app/assets/javascripts/ide/stores/utils.js
app/assets/javascripts/ide/stores/utils.js
+1
-1
app/controllers/ide_controller.rb
app/controllers/ide_controller.rb
+1
-0
app/controllers/projects/merge_requests/creations_controller.rb
...ntrollers/projects/merge_requests/creations_controller.rb
+8
-0
app/views/projects/merge_requests/creations/_new_compare.html.haml
.../projects/merge_requests/creations/_new_compare.html.haml
+2
-0
app/views/projects/merge_requests/creations/_new_submit.html.haml
...s/projects/merge_requests/creations/_new_submit.html.haml
+3
-0
changelogs/unreleased/fj-count-web-ide-merge-requests.yml
changelogs/unreleased/fj-count-web-ide-merge-requests.yml
+5
-0
lib/gitlab/usage_data.rb
lib/gitlab/usage_data.rb
+3
-1
lib/gitlab/usage_data_counters/web_ide_counter.rb
lib/gitlab/usage_data_counters/web_ide_counter.rb
+18
-0
qa/qa/specs/features/browser_ui/3_create/merge_request/rebase_merge_request_spec.rb
...er_ui/3_create/merge_request/rebase_merge_request_spec.rb
+2
-1
spec/controllers/ide_controller_spec.rb
spec/controllers/ide_controller_spec.rb
+17
-0
spec/controllers/projects/merge_requests/creations_controller_spec.rb
...lers/projects/merge_requests/creations_controller_spec.rb
+42
-0
spec/javascripts/ide/stores/modules/commit/actions_spec.js
spec/javascripts/ide/stores/modules/commit/actions_spec.js
+1
-1
spec/lib/gitlab/usage_data_counters/web_ide_counter_spec.rb
spec/lib/gitlab/usage_data_counters/web_ide_counter_spec.rb
+25
-10
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_spec.rb
+10
-0
No files found.
app/assets/javascripts/ide/stores/utils.js
View file @
98e3a1d1
...
...
@@ -159,7 +159,7 @@ export const createCommitPayload = ({
});
export
const
createNewMergeRequestUrl
=
(
projectUrl
,
source
,
target
)
=>
`
${
projectUrl
}
/merge_requests/new?merge_request[source_branch]=
${
source
}
&merge_request[target_branch]=
${
target
}
`
;
`
${
projectUrl
}
/merge_requests/new?merge_request[source_branch]=
${
source
}
&merge_request[target_branch]=
${
target
}
&nav_source=webide
`
;
const
sortTreesByTypeAndName
=
(
a
,
b
)
=>
{
if
(
a
.
type
===
'
tree
'
&&
b
.
type
===
'
blob
'
)
{
...
...
app/controllers/ide_controller.rb
View file @
98e3a1d1
...
...
@@ -4,6 +4,7 @@ class IdeController < ApplicationController
layout
'fullscreen'
def
index
Gitlab
::
UsageDataCounters
::
WebIdeCounter
.
increment_views_count
end
end
...
...
app/controllers/projects/merge_requests/creations_controller.rb
View file @
98e3a1d1
...
...
@@ -23,6 +23,8 @@ class Projects::MergeRequests::CreationsController < Projects::MergeRequests::Ap
@merge_request
=
::
MergeRequests
::
CreateService
.
new
(
project
,
current_user
,
merge_request_params
).
execute
if
@merge_request
.
valid?
incr_count_webide_merge_request
redirect_to
(
merge_request_path
(
@merge_request
))
else
@source_project
=
@merge_request
.
source_project
...
...
@@ -135,4 +137,10 @@ class Projects::MergeRequests::CreationsController < Projects::MergeRequests::Ap
def
whitelist_query_limiting
Gitlab
::
QueryLimiting
.
whitelist
(
'https://gitlab.com/gitlab-org/gitlab-ce/issues/42384'
)
end
def
incr_count_webide_merge_request
return
if
params
[
:nav_source
]
!=
'webide'
Gitlab
::
UsageDataCounters
::
WebIdeCounter
.
increment_merge_requests_count
end
end
app/views/projects/merge_requests/creations/_new_compare.html.haml
View file @
98e3a1d1
...
...
@@ -2,6 +2,8 @@
New Merge Request
=
form_for
[
@project
.
namespace
.
becomes
(
Namespace
),
@project
,
@merge_request
],
url:
project_new_merge_request_path
(
@project
),
method: :get
,
html:
{
class:
"merge-request-form js-requires-input"
}
do
|
f
|
-
if
params
[
:nav_source
].
present?
=
hidden_field_tag
(
:nav_source
,
params
[
:nav_source
])
.hide.alert.alert-danger.mr-compare-errors
.js-merge-request-new-compare.row
{
'data-source-branch-url'
:
project_new_merge_request_branch_from_path
(
@source_project
),
'data-target-branch-url'
:
project_new_merge_request_branch_to_path
(
@source_project
)
}
.col-lg-6
...
...
app/views/projects/merge_requests/creations/_new_submit.html.haml
View file @
98e3a1d1
...
...
@@ -17,6 +17,9 @@
=
f
.
hidden_field
:target_project_id
=
f
.
hidden_field
:target_branch
,
id:
''
-
if
params
[
:nav_source
].
present?
=
hidden_field_tag
(
:nav_source
,
params
[
:nav_source
])
.mr-compare.merge-request.js-merge-request-new-submit
{
'data-mr-submit-action'
:
"#{j params[:tab].presence || 'new'}"
}
-
if
@commits
.
empty?
.commits-empty
...
...
changelogs/unreleased/fj-count-web-ide-merge-requests.yml
0 → 100644
View file @
98e3a1d1
---
title
:
Add Web IDE Usage Ping for Create SMAU
merge_request
:
30800
author
:
type
:
changed
lib/gitlab/usage_data.rb
View file @
98e3a1d1
...
...
@@ -130,7 +130,9 @@ module Gitlab
def
usage_counters
{
web_ide_commits:
Gitlab
::
UsageDataCounters
::
WebIdeCounter
.
total_commits_count
web_ide_commits:
Gitlab
::
UsageDataCounters
::
WebIdeCounter
.
total_commits_count
,
web_ide_merge_requests:
Gitlab
::
UsageDataCounters
::
WebIdeCounter
.
total_merge_requests_count
,
web_ide_views:
Gitlab
::
UsageDataCounters
::
WebIdeCounter
.
total_views_count
}
end
...
...
lib/gitlab/usage_data_counters/web_ide_counter.rb
View file @
98e3a1d1
...
...
@@ -6,6 +6,8 @@ module Gitlab
extend
RedisCounter
COMMITS_COUNT_KEY
=
'WEB_IDE_COMMITS_COUNT'
MERGE_REQUEST_COUNT_KEY
=
'WEB_IDE_MERGE_REQUESTS_COUNT'
VIEWS_COUNT_KEY
=
'WEB_IDE_VIEWS_COUNT'
class
<<
self
def
increment_commits_count
...
...
@@ -15,6 +17,22 @@ module Gitlab
def
total_commits_count
total_count
(
COMMITS_COUNT_KEY
)
end
def
increment_merge_requests_count
increment
(
MERGE_REQUEST_COUNT_KEY
)
end
def
total_merge_requests_count
total_count
(
MERGE_REQUEST_COUNT_KEY
)
end
def
increment_views_count
increment
(
VIEWS_COUNT_KEY
)
end
def
total_views_count
total_count
(
VIEWS_COUNT_KEY
)
end
end
end
end
...
...
qa/qa/specs/features/browser_ui/3_create/merge_request/rebase_merge_request_spec.rb
View file @
98e3a1d1
# frozen_string_literal: true
module
QA
context
'Create'
do
# Failure issue: https://gitlab.com/gitlab-org/quality/staging/issues/66
context
'Create'
,
:quarantine
do
describe
'Merge request rebasing'
do
it
'user rebases source branch of merge request'
do
Runtime
::
Browser
.
visit
(
:gitlab
,
Page
::
Main
::
Login
)
...
...
spec/controllers/ide_controller_spec.rb
0 → 100644
View file @
98e3a1d1
# frozen_string_literal: true
require
'spec_helper'
describe
IdeController
do
let
(
:user
)
{
create
(
:user
)
}
before
do
sign_in
(
user
)
end
it
'increases the views counter'
do
expect
(
Gitlab
::
UsageDataCounters
::
WebIdeCounter
).
to
receive
(
:increment_views_count
)
get
:index
end
end
spec/controllers/projects/merge_requests/creations_controller_spec.rb
View file @
98e3a1d1
...
...
@@ -212,4 +212,46 @@ describe Projects::MergeRequests::CreationsController do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
end
describe
'POST create'
do
let
(
:params
)
do
{
namespace_id:
fork_project
.
namespace
.
to_param
,
project_id:
fork_project
,
merge_request:
{
title:
'Test merge request'
,
source_branch:
'remove-submodule'
,
target_branch:
'master'
}
}
end
it
'creates merge request'
do
expect
do
post_request
(
params
)
end
.
to
change
{
MergeRequest
.
count
}.
by
(
1
)
end
context
'when the merge request is not created from the web ide'
do
it
'counter is not increased'
do
expect
(
Gitlab
::
UsageDataCounters
::
WebIdeCounter
).
not_to
receive
(
:increment_merge_requests_count
)
post_request
(
params
)
end
end
context
'when the merge request is created from the web ide'
do
let
(
:nav_source
)
{
{
nav_source:
'webide'
}
}
it
'counter is increased'
do
expect
(
Gitlab
::
UsageDataCounters
::
WebIdeCounter
).
to
receive
(
:increment_merge_requests_count
)
post_request
(
params
.
merge
(
nav_source
))
end
end
def
post_request
(
merge_request_params
)
post
:create
,
params:
merge_request_params
end
end
end
spec/javascripts/ide/stores/modules/commit/actions_spec.js
View file @
98e3a1d1
...
...
@@ -411,7 +411,7 @@ describe('IDE commit module actions', () => {
expect
(
visitUrl
).
toHaveBeenCalledWith
(
`webUrl/merge_requests/new?merge_request[source_branch]=
${
store
.
getters
[
'
commit/placeholderBranchName
'
]
}
&merge_request[target_branch]=master`
,
}
&merge_request[target_branch]=master
&nav_source=webide
`
,
);
done
();
...
...
spec/lib/gitlab/usage_data_counters/web_ide_counter_spec.rb
View file @
98e3a1d1
...
...
@@ -3,19 +3,34 @@
require
'spec_helper'
describe
Gitlab
::
UsageDataCounters
::
WebIdeCounter
,
:clean_gitlab_redis_shared_state
do
describe
'.increment_commits_count'
do
it
'increments the web ide commits counter by 1'
do
expect
do
described_class
.
increment_commits_count
end
.
to
change
{
described_class
.
total_commits_count
}.
by
(
1
)
shared_examples
'counter examples'
do
it
'increments counter and return the total count'
do
expect
(
described_class
.
public_send
(
total_counter_method
)).
to
eq
(
0
)
2
.
times
{
described_class
.
public_send
(
increment_counter_method
)
}
expect
(
described_class
.
public_send
(
total_counter_method
)).
to
eq
(
2
)
end
end
describe
'
.total_commits_count
'
do
it
'returns the total amount of web ide commits'
do
2
.
times
{
described_class
.
increment
_commits_count
}
describe
'
commits counter
'
do
let
(
:increment_counter_method
)
{
:increment_commits_count
}
let
(
:total_counter_method
)
{
:total
_commits_count
}
expect
(
described_class
.
total_commits_count
).
to
eq
(
2
)
end
it_behaves_like
'counter examples'
end
describe
'merge requests counter'
do
let
(
:increment_counter_method
)
{
:increment_merge_requests_count
}
let
(
:total_counter_method
)
{
:total_merge_requests_count
}
it_behaves_like
'counter examples'
end
describe
'views counter'
do
let
(
:increment_counter_method
)
{
:increment_views_count
}
let
(
:total_counter_method
)
{
:total_views_count
}
it_behaves_like
'counter examples'
end
end
spec/lib/gitlab/usage_data_spec.rb
View file @
98e3a1d1
...
...
@@ -57,12 +57,22 @@ describe Gitlab::UsageData do
gitaly
database
avg_cycle_analytics
web_ide_views
web_ide_commits
web_ide_merge_requests
influxdb_metrics_enabled
prometheus_metrics_enabled
)
)
end
it
'calls expected usage data methods'
do
expect
(
Gitlab
::
UsageDataCounters
::
WebIdeCounter
).
to
receive
(
:total_commits_count
)
expect
(
Gitlab
::
UsageDataCounters
::
WebIdeCounter
).
to
receive
(
:total_merge_requests_count
)
expect
(
Gitlab
::
UsageDataCounters
::
WebIdeCounter
).
to
receive
(
:total_views_count
)
subject
end
it
"gathers usage counts"
do
expected_keys
=
%i(
assignee_lists
...
...
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