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
Boxiang Sun
gitlab-ce
Commits
c53afeda
Commit
c53afeda
authored
Apr 05, 2017
by
Sean McGivern
Committed by
Rémy Coutable
Apr 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port 'Add uuid to usage ping' to CE
CE port of
https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1521
parent
f5b42881
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
2 deletions
+24
-2
db/migrate/20170328010804_add_uuid_to_application_settings.rb
...igrate/20170328010804_add_uuid_to_application_settings.rb
+16
-0
db/schema.rb
db/schema.rb
+1
-0
lib/gitlab/usage_data.rb
lib/gitlab/usage_data.rb
+4
-1
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_spec.rb
+3
-1
No files found.
db/migrate/20170328010804_add_uuid_to_application_settings.rb
0 → 100644
View file @
c53afeda
class
AddUuidToApplicationSettings
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
add_column
:application_settings
,
:uuid
,
:string
execute
(
"UPDATE application_settings SET uuid =
#{
quote
(
SecureRandom
.
uuid
)
}
"
)
end
def
down
remove_column
:application_settings
,
:uuid
end
end
db/schema.rb
View file @
c53afeda
...
...
@@ -117,6 +117,7 @@ ActiveRecord::Schema.define(version: 20170408033905) do
t
.
boolean
"unique_ips_limit_enabled"
,
default:
false
,
null:
false
t
.
decimal
"polling_interval_multiplier"
,
default:
1.0
,
null:
false
t
.
boolean
"usage_ping_enabled"
,
default:
true
,
null:
false
t
.
string
"uuid"
end
create_table
"audit_events"
,
force: :cascade
do
|
t
|
...
...
lib/gitlab/usage_data.rb
View file @
c53afeda
module
Gitlab
class
UsageData
include
Gitlab
::
CurrentSettings
class
<<
self
def
data
Rails
.
cache
.
fetch
(
'usage_data'
,
expires_in:
1
.
hour
)
{
uncached_data
}
...
...
@@ -45,7 +47,8 @@ module Gitlab
end
def
license_usage_data
usage_data
=
{
version:
Gitlab
::
VERSION
,
usage_data
=
{
uuid:
current_application_settings
.
uuid
,
version:
Gitlab
::
VERSION
,
active_user_count:
User
.
active
.
count
,
recorded_at:
Time
.
now
,
mattermost_enabled:
Gitlab
.
config
.
mattermost
.
enabled
}
...
...
spec/lib/gitlab/usage_data_spec.rb
View file @
c53afeda
...
...
@@ -12,9 +12,10 @@ describe Gitlab::UsageData do
expect
(
subject
.
keys
).
to
match_array
(
%i(
active_user_count
counts
version
recorded_at
mattermost_enabled
version
uuid
)
)
end
...
...
@@ -57,6 +58,7 @@ describe Gitlab::UsageData do
subject
{
Gitlab
::
UsageData
.
license_usage_data
}
it
"gathers license data"
do
expect
(
subject
[
:uuid
]).
to
eq
(
current_application_settings
.
uuid
)
expect
(
subject
[
:version
]).
to
eq
(
Gitlab
::
VERSION
)
expect
(
subject
[
:active_user_count
]).
to
eq
(
User
.
active
.
count
)
expect
(
subject
[
:recorded_at
]).
to
be_a
(
Time
)
...
...
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