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
4d1f1ac7
Commit
4d1f1ac7
authored
Apr 01, 2020
by
alinamihaila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify the alt_usage_data usage
parent
517e78d7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
40 deletions
+17
-40
lib/gitlab/usage_data.rb
lib/gitlab/usage_data.rb
+17
-40
No files found.
lib/gitlab/usage_data.rb
View file @
4d1f1ac7
...
...
@@ -4,8 +4,6 @@ module Gitlab
class
UsageData
BATCH_SIZE
=
100
@alt_counters
=
{}
class
<<
self
def
data
(
force_refresh:
false
)
Rails
.
cache
.
fetch
(
'usage_data'
,
force:
force_refresh
,
expires_in:
2
.
weeks
)
do
...
...
@@ -26,8 +24,15 @@ module Gitlab
end
def
license_usage_data
alt_counters
.
merge
(
active_user_count:
count
(
User
.
active
))
{
uuid:
alt_usage_data
(
:uuid
)
{
Gitlab
::
CurrentSettings
.
uuid
},
hostname:
alt_usage_data
(
:hostname
)
{
Gitlab
.
config
.
gitlab
.
host
},
version:
alt_usage_data
(
:version
)
{
Gitlab
::
VERSION
},
installation_type:
alt_usage_data
(
:installation_type
)
{
installation_type
},
active_user_count:
count
(
User
.
active
),
recorded_at:
alt_usage_data
(
:recorded_at
)
{
Time
.
now
},
edition:
alt_usage_data
(
:edition
,
'CE'
)
}
end
# rubocop: disable Metrics/AbcSize
...
...
@@ -253,8 +258,14 @@ module Gitlab
fallback
end
def
alt_usage_data
(
attribute_key
,
value
=
nil
,
&
block
)
@alt_counters
[
attribute_key
]
=
block_given?
?
block
:
value
def
alt_usage_data
(
attribute_key
,
value
=
nil
,
fallback:
-
1
,
&
block
)
if
block_given?
instance_eval
(
&
block
)
else
value
end
rescue
Errno
::
ENOENT
fallback
end
private
...
...
@@ -266,41 +277,7 @@ module Gitlab
"gitlab-development-kit"
end
end
def
alt_counters
@alt_counters
.
each_with_object
({})
do
|
counter
,
result
|
value
=
if
counter
[
1
].
is_a?
(
Proc
)
instance_eval
(
&
counter
[
1
])
else
counter
[
1
]
end
result
[
counter
[
0
]]
=
value
end
end
end
alt_usage_data
:uuid
do
Gitlab
::
CurrentSettings
.
uuid
end
alt_usage_data
:installation_type
do
installation_type
end
alt_usage_data
:hostname
do
Gitlab
.
config
.
gitlab
.
host
end
alt_usage_data
:version
do
Gitlab
::
VERSION
end
alt_usage_data
:recorded_at
do
Time
.
now
end
alt_usage_data
:edition
,
'CE'
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