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
a77239f2
Commit
a77239f2
authored
Mar 09, 2021
by
Piotr Skorupa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor handling Usage Ping response
parent
dd292f11
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
13 deletions
+4
-13
app/models/raw_usage_data.rb
app/models/raw_usage_data.rb
+2
-6
app/services/submit_usage_ping_service.rb
app/services/submit_usage_ping_service.rb
+2
-7
No files found.
app/models/raw_usage_data.rb
View file @
a77239f2
...
@@ -4,11 +4,7 @@ class RawUsageData < ApplicationRecord
...
@@ -4,11 +4,7 @@ class RawUsageData < ApplicationRecord
validates
:payload
,
presence:
true
validates
:payload
,
presence:
true
validates
:recorded_at
,
presence:
true
,
uniqueness:
true
validates
:recorded_at
,
presence:
true
,
uniqueness:
true
def
update_sent_at!
def
update_version_metadata!
(
usage_data_id
:)
self
.
update_column
(
:sent_at
,
Time
.
current
)
self
.
update_columns
(
sent_at:
Time
.
current
,
version_usage_data_id_value:
usage_data_id
)
end
def
update_version_usage_data_id!
(
usage_data_id
)
self
.
update_column
(
:version_usage_data_id_value
,
usage_data_id
)
end
end
end
end
app/services/submit_usage_ping_service.rb
View file @
a77239f2
...
@@ -35,15 +35,10 @@ class SubmitUsagePingService
...
@@ -35,15 +35,10 @@ class SubmitUsagePingService
raise
SubmissionError
.
new
(
"Unsuccessful response code:
#{
response
.
code
}
"
)
unless
response
.
success?
raise
SubmissionError
.
new
(
"Unsuccessful response code:
#{
response
.
code
}
"
)
unless
response
.
success?
RawUsageData
.
transaction
do
raw_usage_data
.
update_version_metadata!
(
usage_data_id:
response
.
dig
(
'conv_index'
,
'usage_data_id'
))
if
raw_usage_data
raw_usage_data
.
update_sent_at!
raw_usage_data
.
update_version_usage_data_id!
(
response
.
dig
(
'conv_index'
,
'usage_data_id'
))
end
store_metrics
(
response
)
store_metrics
(
response
)
end
end
end
private
private
...
...
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