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
934bca8c
Commit
934bca8c
authored
Dec 24, 2020
by
Pavel Shutsin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Schedule immediate snapshot calculation
So user sees snapshot data for current month immediately after creation
parent
aaeddaa7
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
13 deletions
+21
-13
ee/app/services/analytics/devops_adoption/segments/create_service.rb
...ices/analytics/devops_adoption/segments/create_service.rb
+2
-0
ee/changelogs/unreleased/289856-immediately-calculate-snapshot.yml
...logs/unreleased/289856-immediately-calculate-snapshot.yml
+5
-0
ee/db/fixtures/development/31_devops_adoption.rb
ee/db/fixtures/development/31_devops_adoption.rb
+6
-13
ee/spec/services/analytics/devops_adoption/segments/create_service_spec.rb
...analytics/devops_adoption/segments/create_service_spec.rb
+8
-0
No files found.
ee/app/services/analytics/devops_adoption/segments/create_service.rb
View file @
934bca8c
...
@@ -20,6 +20,8 @@ module Analytics
...
@@ -20,6 +20,8 @@ module Analytics
segment
.
assign_attributes
(
attributes
)
segment
.
assign_attributes
(
attributes
)
if
segment
.
save
if
segment
.
save
Analytics
::
DevopsAdoption
::
CreateSnapshotWorker
.
perform_async
(
segment
.
id
,
nil
)
ServiceResponse
.
success
(
payload:
response_payload
)
ServiceResponse
.
success
(
payload:
response_payload
)
else
else
ServiceResponse
.
error
(
message:
'Validation error'
,
payload:
response_payload
)
ServiceResponse
.
error
(
message:
'Validation error'
,
payload:
response_payload
)
...
...
ee/changelogs/unreleased/289856-immediately-calculate-snapshot.yml
0 → 100644
View file @
934bca8c
---
title
:
Immediately calculate devops adoption data after segment creation
merge_request
:
50619
author
:
type
:
changed
ee/db/fixtures/development/31_devops_adoption.rb
View file @
934bca8c
# frozen_string_literal: true
# frozen_string_literal: true
Gitlab
::
Seeder
.
quiet
do
Gitlab
::
Seeder
.
quiet
do
admin
=
User
.
where
(
admin:
true
).
first
if
admin
.
nil?
puts
"No admin user present"
next
end
groups
=
Group
.
take
(
5
)
groups
=
Group
.
take
(
5
)
next
if
groups
.
empty?
next
if
groups
.
empty?
...
@@ -16,10 +9,10 @@ Gitlab::Seeder.quiet do
...
@@ -16,10 +9,10 @@ Gitlab::Seeder.quiet do
segment_groups_2
=
groups
.
sample
(
3
)
segment_groups_2
=
groups
.
sample
(
3
)
ActiveRecord
::
Base
.
transaction
do
ActiveRecord
::
Base
.
transaction
do
segment
_1
=
Analytics
::
DevopsAdoption
::
Segments
::
CreateService
.
new
(
params:
{
name:
'Segment 1'
,
groups:
segment_groups_1
},
current_user:
admin
).
execute
segment
s
=
[
segment_2
=
Analytics
::
DevopsAdoption
::
Segments
::
CreateService
.
new
(
params:
{
name:
'Segment 2'
,
groups:
segment_groups_2
},
current_user:
admin
).
execute
Analytics
::
DevopsAdoption
::
Segment
.
create
(
name:
'Segment 1'
,
groups:
segment_groups_1
),
Analytics
::
DevopsAdoption
::
Segment
.
create
(
name:
'Segment 2'
,
groups:
segment_groups_2
)
segments
=
[
segment_1
.
payload
[
:segment
],
segment_2
.
payload
[
:segment
]
]
]
if
segments
.
any?
(
&
:invalid?
)
if
segments
.
any?
(
&
:invalid?
)
puts
"Error creating segments"
puts
"Error creating segments"
...
@@ -50,7 +43,7 @@ Gitlab::Seeder.quiet do
...
@@ -50,7 +43,7 @@ Gitlab::Seeder.quiet do
Analytics
::
DevopsAdoption
::
Snapshots
::
CreateService
.
new
(
params:
calculated_data
).
execute
Analytics
::
DevopsAdoption
::
Snapshots
::
CreateService
.
new
(
params:
calculated_data
).
execute
end
end
end
end
end
print
'.'
print
'.'
end
end
end
ee/spec/services/analytics/devops_adoption/segments/create_service_spec.rb
View file @
934bca8c
...
@@ -23,6 +23,14 @@ RSpec.describe Analytics::DevopsAdoption::Segments::CreateService do
...
@@ -23,6 +23,14 @@ RSpec.describe Analytics::DevopsAdoption::Segments::CreateService do
expect
(
segment
.
groups
).
to
eq
([
group
])
expect
(
segment
.
groups
).
to
eq
([
group
])
end
end
it
'schedules for snapshot creation'
do
allow
(
Analytics
::
DevopsAdoption
::
CreateSnapshotWorker
).
to
receive
(
:perform_async
).
and_call_original
subject
expect
(
Analytics
::
DevopsAdoption
::
CreateSnapshotWorker
).
to
have_received
(
:perform_async
).
with
(
Analytics
::
DevopsAdoption
::
Segment
.
last
.
id
,
nil
)
end
context
'when user is not an admin'
do
context
'when user is not an admin'
do
let
(
:user
)
{
build
(
:user
)
}
let
(
:user
)
{
build
(
:user
)
}
...
...
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