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
5ac38271
Commit
5ac38271
authored
Jul 12, 2021
by
Adam Hegyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce hash_code for VSA stages and events
This change adds the hash_code methods for stages and events.
parent
62c9b458
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
53 additions
and
4 deletions
+53
-4
app/models/concerns/analytics/cycle_analytics/stage.rb
app/models/concerns/analytics/cycle_analytics/stage.rb
+4
-0
ee/lib/gitlab/analytics/cycle_analytics/stage_events/label_based_stage_event.rb
...s/cycle_analytics/stage_events/label_based_stage_event.rb
+4
-0
ee/spec/lib/gitlab/analytics/cycle_analytics/stage_events/issue_label_added_spec.rb
...cs/cycle_analytics/stage_events/issue_label_added_spec.rb
+3
-1
ee/spec/lib/gitlab/analytics/cycle_analytics/stage_events/issue_label_removed_spec.rb
.../cycle_analytics/stage_events/issue_label_removed_spec.rb
+3
-1
ee/spec/lib/gitlab/analytics/cycle_analytics/stage_events/merge_request_label_added_spec.rb
..._analytics/stage_events/merge_request_label_added_spec.rb
+3
-1
ee/spec/lib/gitlab/analytics/cycle_analytics/stage_events/merge_request_label_removed_spec.rb
...nalytics/stage_events/merge_request_label_removed_spec.rb
+3
-1
lib/gitlab/analytics/cycle_analytics/stage_events/stage_event.rb
...lab/analytics/cycle_analytics/stage_events/stage_event.rb
+4
-0
spec/support/shared_examples/lib/gitlab/cycle_analytics/event_shared_examples.rb
...mples/lib/gitlab/cycle_analytics/event_shared_examples.rb
+13
-0
spec/support/shared_examples/models/cycle_analytics_stage_shared_examples.rb
..._examples/models/cycle_analytics_stage_shared_examples.rb
+16
-0
No files found.
app/models/concerns/analytics/cycle_analytics/stage.rb
View file @
5ac38271
...
...
@@ -50,6 +50,10 @@ module Analytics
end
end
def
events_hash_code
Digest
::
SHA256
.
hexdigest
(
"
#{
start_event
.
hash_code
}
-
#{
end_event
.
hash_code
}
"
)
end
def
start_event_label_based?
start_event_identifier
&&
start_event
.
label_based?
end
...
...
ee/lib/gitlab/analytics/cycle_analytics/stage_events/label_based_stage_event.rb
View file @
5ac38271
...
...
@@ -20,6 +20,10 @@ module Gitlab
true
end
def
hash_code
Digest
::
SHA256
.
hexdigest
(
"
#{
self
.
class
.
identifier
}
-
#{
label_id
}
"
)
end
def
column_list
[
Arel
.
sql
(
"
#{
join_expression_name
}
.created_at"
)]
end
...
...
ee/spec/lib/gitlab/analytics/cycle_analytics/stage_events/issue_label_added_spec.rb
View file @
5ac38271
...
...
@@ -4,6 +4,8 @@ require 'spec_helper'
RSpec
.
describe
Gitlab
::
Analytics
::
CycleAnalytics
::
StageEvents
::
IssueLabelAdded
do
it_behaves_like
'value stream analytics event'
do
let
(
:params
)
{
{
label:
GroupLabel
.
new
}
}
let
(
:label_id
)
{
10
}
let
(
:params
)
{
{
label:
GroupLabel
.
new
(
id:
label_id
)
}
}
let
(
:expected_hash_code
)
{
Digest
::
SHA256
.
hexdigest
(
"
#{
instance
.
class
.
identifier
}
-
#{
label_id
}
"
)
}
end
end
ee/spec/lib/gitlab/analytics/cycle_analytics/stage_events/issue_label_removed_spec.rb
View file @
5ac38271
...
...
@@ -4,6 +4,8 @@ require 'spec_helper'
RSpec
.
describe
Gitlab
::
Analytics
::
CycleAnalytics
::
StageEvents
::
IssueLabelRemoved
do
it_behaves_like
'value stream analytics event'
do
let
(
:params
)
{
{
label:
GroupLabel
.
new
}
}
let
(
:label_id
)
{
10
}
let
(
:params
)
{
{
label:
GroupLabel
.
new
(
id:
label_id
)
}
}
let
(
:expected_hash_code
)
{
Digest
::
SHA256
.
hexdigest
(
"
#{
instance
.
class
.
identifier
}
-
#{
label_id
}
"
)
}
end
end
ee/spec/lib/gitlab/analytics/cycle_analytics/stage_events/merge_request_label_added_spec.rb
View file @
5ac38271
...
...
@@ -4,6 +4,8 @@ require 'spec_helper'
RSpec
.
describe
Gitlab
::
Analytics
::
CycleAnalytics
::
StageEvents
::
MergeRequestLabelAdded
do
it_behaves_like
'value stream analytics event'
do
let
(
:params
)
{
{
label:
GroupLabel
.
new
}
}
let
(
:label_id
)
{
10
}
let
(
:params
)
{
{
label:
GroupLabel
.
new
(
id:
label_id
)
}
}
let
(
:expected_hash_code
)
{
Digest
::
SHA256
.
hexdigest
(
"
#{
instance
.
class
.
identifier
}
-
#{
label_id
}
"
)
}
end
end
ee/spec/lib/gitlab/analytics/cycle_analytics/stage_events/merge_request_label_removed_spec.rb
View file @
5ac38271
...
...
@@ -4,6 +4,8 @@ require 'spec_helper'
RSpec
.
describe
Gitlab
::
Analytics
::
CycleAnalytics
::
StageEvents
::
MergeRequestLabelRemoved
do
it_behaves_like
'value stream analytics event'
do
let
(
:params
)
{
{
label:
GroupLabel
.
new
}
}
let
(
:label_id
)
{
10
}
let
(
:params
)
{
{
label:
GroupLabel
.
new
(
id:
label_id
)
}
}
let
(
:expected_hash_code
)
{
Digest
::
SHA256
.
hexdigest
(
"
#{
instance
.
class
.
identifier
}
-
#{
label_id
}
"
)
}
end
end
lib/gitlab/analytics/cycle_analytics/stage_events/stage_event.rb
View file @
5ac38271
...
...
@@ -31,6 +31,10 @@ module Gitlab
raise
NotImplementedError
end
def
hash_code
Digest
::
SHA256
.
hexdigest
(
self
.
class
.
identifier
.
to_s
)
end
# Each StageEvent must expose a timestamp or a timestamp like expression in order to build a range query.
# Example: get me all the Issue records between start event end end event
def
timestamp_projection
...
...
spec/support/shared_examples/lib/gitlab/cycle_analytics/event_shared_examples.rb
View file @
5ac38271
...
...
@@ -3,6 +3,7 @@
RSpec
.
shared_examples_for
'value stream analytics event'
do
let
(
:params
)
{
{}
}
let
(
:instance
)
{
described_class
.
new
(
params
)
}
let
(
:expected_hash_code
)
{
Digest
::
SHA256
.
hexdigest
(
instance
.
class
.
identifier
.
to_s
)
}
it
{
expect
(
described_class
.
name
).
to
be_a_kind_of
(
String
)
}
it
{
expect
(
described_class
.
identifier
).
to
be_a_kind_of
(
Symbol
)
}
...
...
@@ -19,4 +20,16 @@ RSpec.shared_examples_for 'value stream analytics event' do
expect
(
output_query
).
to
be_a_kind_of
(
ActiveRecord
::
Relation
)
end
end
describe
'#hash_code'
do
it
'returns a hash that uniquely identifies an event'
do
expect
(
instance
.
hash_code
).
to
eq
(
expected_hash_code
)
end
it
'does not differ when the same object is built with the same params'
do
another_instance_with_same_params
=
described_class
.
new
(
params
)
expect
(
another_instance_with_same_params
.
hash_code
).
to
eq
(
instance
.
hash_code
)
end
end
end
spec/support/shared_examples/models/cycle_analytics_stage_shared_examples.rb
View file @
5ac38271
...
...
@@ -122,6 +122,22 @@ RSpec.shared_examples 'value stream analytics stage' do
expect
(
stage
.
parent_id
).
to
eq
(
parent
.
id
)
end
end
describe
'#hash_code'
do
it
'does not differ when the same object is built with the same params'
do
stage_1
=
build
(
factory
)
stage_2
=
build
(
factory
)
expect
(
stage_1
.
events_hash_code
).
to
eq
(
stage_2
.
events_hash_code
)
end
it
'differs when the stage events are different'
do
stage_1
=
build
(
factory
,
start_event_identifier: :merge_request_created
,
end_event_identifier: :merge_request_merged
)
stage_2
=
build
(
factory
,
start_event_identifier: :issue_created
,
end_event_identifier: :issue_first_mentioned_in_commit
)
expect
(
stage_1
.
events_hash_code
).
not_to
eq
(
stage_2
.
events_hash_code
)
end
end
end
RSpec
.
shared_examples
'value stream analytics label based stage'
do
...
...
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