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
bcf2b20c
Commit
bcf2b20c
authored
Jul 16, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
65770d3e
77c8fe01
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
89 additions
and
22 deletions
+89
-22
lib/api/commits.rb
lib/api/commits.rb
+1
-1
lib/gitlab/usage_data.rb
lib/gitlab/usage_data.rb
+1
-1
lib/gitlab/usage_data_counters/redis_counter.rb
lib/gitlab/usage_data_counters/redis_counter.rb
+19
-0
lib/gitlab/usage_data_counters/web_ide_commits_counter.rb
lib/gitlab/usage_data_counters/web_ide_commits_counter.rb
+13
-0
spec/lib/gitlab/usage_data_counters/redis_counter_spec.rb
spec/lib/gitlab/usage_data_counters/redis_counter_spec.rb
+54
-0
spec/lib/gitlab/web_ide_commits_counter_spec.rb
spec/lib/gitlab/web_ide_commits_counter_spec.rb
+0
-19
spec/requests/api/commits_spec.rb
spec/requests/api/commits_spec.rb
+1
-1
No files found.
lib/api/commits.rb
View file @
bcf2b20c
...
...
@@ -126,7 +126,7 @@ module API
if
result
[
:status
]
==
:success
commit_detail
=
user_project
.
repository
.
commit
(
result
[
:result
])
Gitlab
::
WebIdeCommitsCounter
.
increment
if
find_user_from_warden
Gitlab
::
UsageDataCounters
::
WebIdeCommitsCounter
.
increment
if
find_user_from_warden
present
commit_detail
,
with:
Entities
::
CommitDetail
,
stats:
params
[
:stats
]
else
...
...
lib/gitlab/usage_data.rb
View file @
bcf2b20c
...
...
@@ -130,7 +130,7 @@ module Gitlab
def
usage_counters
{
web_ide_commits:
Gitlab
::
WebIdeCommitsCounter
.
total_count
web_ide_commits:
Gitlab
::
UsageDataCounters
::
WebIdeCommitsCounter
.
total_count
}
end
...
...
lib/gitlab/
web_ide_commit
s_counter.rb
→
lib/gitlab/
usage_data_counters/redi
s_counter.rb
View file @
bcf2b20c
# frozen_string_literal: true
module
Gitlab
module
WebIdeCommitsCounter
WEB_IDE_COMMITS_KEY
=
"WEB_IDE_COMMITS_COUNT"
.
freeze
class
<<
self
module
UsageDataCounters
module
RedisCounter
def
increment
Gitlab
::
Redis
::
SharedState
.
with
{
|
redis
|
redis
.
incr
(
WEB_IDE_COMMITS_KEY
)
}
Gitlab
::
Redis
::
SharedState
.
with
{
|
redis
|
redis
.
incr
(
redis_counter_key
)
}
end
def
total_count
Gitlab
::
Redis
::
SharedState
.
with
{
|
redis
|
redis
.
get
(
WEB_IDE_COMMITS_KEY
).
to_i
}
Gitlab
::
Redis
::
SharedState
.
with
{
|
redis
|
redis
.
get
(
redis_counter_key
).
to_i
}
end
def
redis_counter_key
raise
NotImplementedError
end
end
end
...
...
lib/gitlab/usage_data_counters/web_ide_commits_counter.rb
0 → 100644
View file @
bcf2b20c
# frozen_string_literal: true
module
Gitlab
module
UsageDataCounters
class
WebIdeCommitsCounter
extend
RedisCounter
def
self
.
redis_counter_key
'WEB_IDE_COMMITS_COUNT'
end
end
end
end
spec/lib/gitlab/usage_data_counters/redis_counter_spec.rb
0 → 100644
View file @
bcf2b20c
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
UsageDataCounters
::
RedisCounter
,
:clean_gitlab_redis_shared_state
do
context
'when redis_key is not defined'
do
subject
do
Class
.
new
.
extend
(
described_class
)
end
describe
'.increment'
do
it
'raises a NotImplementedError exception'
do
expect
{
subject
.
increment
}.
to
raise_error
(
NotImplementedError
)
end
end
describe
'.total_count'
do
it
'raises a NotImplementedError exception'
do
expect
{
subject
.
total_count
}.
to
raise_error
(
NotImplementedError
)
end
end
end
context
'when redis_key is defined'
do
subject
do
counter_module
=
described_class
Class
.
new
do
extend
counter_module
def
self
.
redis_counter_key
'foo_redis_key'
end
end
end
describe
'.increment'
do
it
'increments the web ide commits counter by 1'
do
expect
do
subject
.
increment
end
.
to
change
{
subject
.
total_count
}.
from
(
0
).
to
(
1
)
end
end
describe
'.total_count'
do
it
'returns the total amount of web ide commits'
do
subject
.
increment
subject
.
increment
expect
(
subject
.
total_count
).
to
eq
(
2
)
end
end
end
end
spec/lib/gitlab/web_ide_commits_counter_spec.rb
deleted
100644 → 0
View file @
65770d3e
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
WebIdeCommitsCounter
,
:clean_gitlab_redis_shared_state
do
describe
'.increment'
do
it
'increments the web ide commits counter by 1'
do
expect
do
described_class
.
increment
end
.
to
change
{
described_class
.
total_count
}.
from
(
0
).
to
(
1
)
end
end
describe
'.total_count'
do
it
'returns the total amount of web ide commits'
do
expect
(
described_class
.
total_count
).
to
eq
(
0
)
end
end
end
spec/requests/api/commits_spec.rb
View file @
bcf2b20c
...
...
@@ -281,7 +281,7 @@ describe API::Commits do
end
it
'does not increment the usage counters using access token authentication'
do
expect
(
::
Gitlab
::
WebIdeCommitsCounter
).
not_to
receive
(
:increment
)
expect
(
::
Gitlab
::
UsageDataCounters
::
WebIdeCommitsCounter
).
not_to
receive
(
:increment
)
post
api
(
url
,
user
),
params:
valid_c_params
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