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
1b3f0d30
Commit
1b3f0d30
authored
Sep 11, 2020
by
Heinrich Lee Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove track_issue_weight_change_events flag
This feature flag has been enabled by default for a while now
parent
49d7ee1e
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
39 additions
and
128 deletions
+39
-128
.rubocop_todo.yml
.rubocop_todo.yml
+0
-1
ee/app/services/ee/issuable/common_system_notes_service.rb
ee/app/services/ee/issuable/common_system_notes_service.rb
+1
-9
ee/app/services/ee/system_note_service.rb
ee/app/services/ee/system_note_service.rb
+0
-17
ee/app/services/ee/system_notes/issuables_service.rb
ee/app/services/ee/system_notes/issuables_service.rb
+0
-15
ee/app/services/resource_events/change_weight_service.rb
ee/app/services/resource_events/change_weight_service.rb
+32
-0
ee/spec/requests/api/issues_spec.rb
ee/spec/requests/api/issues_spec.rb
+0
-18
ee/spec/services/ee/issuable/common_system_notes_service_spec.rb
.../services/ee/issuable/common_system_notes_service_spec.rb
+4
-26
ee/spec/services/ee/system_notes/issuables_service_spec.rb
ee/spec/services/ee/system_notes/issuables_service_spec.rb
+0
-30
ee/spec/services/resource_events/change_weight_service_spec.rb
...ec/services/resource_events/change_weight_service_spec.rb
+2
-2
ee/spec/services/system_note_service_spec.rb
ee/spec/services/system_note_service_spec.rb
+0
-10
No files found.
.rubocop_todo.yml
View file @
1b3f0d30
...
...
@@ -773,7 +773,6 @@ Rails/SaveBang:
-
'
ee/spec/services/ee/merge_requests/update_service_spec.rb'
-
'
ee/spec/services/ee/notes/quick_actions_service_spec.rb'
-
'
ee/spec/services/ee/notification_service_spec.rb'
-
'
ee/spec/services/ee/resource_events/change_weight_service_spec.rb'
-
'
ee/spec/services/epic_links/create_service_spec.rb'
-
'
ee/spec/services/epics/close_service_spec.rb'
-
'
ee/spec/services/epics/issue_promote_service_spec.rb'
...
...
ee/app/services/ee/issuable/common_system_notes_service.rb
View file @
1b3f0d30
...
...
@@ -46,11 +46,7 @@ module EE
def
handle_weight_change
return
unless
issuable
.
previous_changes
.
include?
(
'weight'
)
if
weight_changes_tracking_enabled?
EE
::
ResourceEvents
::
ChangeWeightService
.
new
([
issuable
],
current_user
,
Time
.
current
).
execute
else
::
SystemNoteService
.
change_weight_note
(
issuable
,
issuable
.
project
,
current_user
)
end
::
ResourceEvents
::
ChangeWeightService
.
new
([
issuable
],
current_user
,
Time
.
current
).
execute
end
def
handle_health_status_change
...
...
@@ -59,10 +55,6 @@ module EE
::
SystemNoteService
.
change_health_status_note
(
issuable
,
issuable
.
project
,
current_user
)
end
def
weight_changes_tracking_enabled?
!
issuable
.
is_a?
(
Epic
)
&&
::
Feature
.
enabled?
(
:track_issue_weight_change_events
,
issuable
.
project
,
default_enabled:
true
)
end
def
iteration_changes_tracking_enabled?
::
Feature
.
enabled?
(
:track_iteration_change_events
,
issuable
.
project
,
default_enabled:
true
)
end
...
...
ee/app/services/ee/system_note_service.rb
View file @
1b3f0d30
...
...
@@ -40,23 +40,6 @@ module EE
issuables_service
(
noteable
,
noteable
.
project
,
author
).
change_iteration
(
iteration
)
end
# Called when the weight of a Noteable is changed
#
# noteable - Noteable object
# project - Project owning noteable
# author - User performing the change
#
# Example Note text:
#
# "removed the weight"
#
# "changed weight to 4"
#
# Returns the created Note object
def
change_weight_note
(
noteable
,
project
,
author
)
issuables_service
(
noteable
,
project
,
author
).
change_weight_note
end
# Called when the health_stauts of an Issue is changed
#
# noteable - Noteable object
...
...
ee/app/services/ee/system_notes/issuables_service.rb
View file @
1b3f0d30
...
...
@@ -2,21 +2,6 @@
module
EE
module
SystemNotes
module
IssuablesService
# Called when the weight of a Noteable is changed
#
# Example Note text:
#
# "removed the weight"
#
# "changed weight to 4"
#
# Returns the created Note object
def
change_weight_note
body
=
noteable
.
weight
?
"changed weight to **
#{
noteable
.
weight
}
**"
:
'removed the weight'
create_note
(
NoteSummary
.
new
(
noteable
,
project
,
author
,
body
,
action:
'weight'
))
end
# Called when the health_status of an Issue is changed
#
# Example Note text:
...
...
ee/app/services/resource_events/change_weight_service.rb
0 → 100644
View file @
1b3f0d30
# frozen_string_literal: true
module
ResourceEvents
class
ChangeWeightService
attr_reader
:resources
,
:user
,
:event_created_at
def
initialize
(
resources
,
user
,
created_at
)
@resources
=
resources
@user
=
user
@event_created_at
=
created_at
end
def
execute
unless
resource_weight_changes
.
empty?
::
Gitlab
::
Database
.
bulk_insert
(
ResourceWeightEvent
.
table_name
,
resource_weight_changes
)
# rubocop:disable Gitlab/BulkInsert
resources
.
each
(
&
:expire_note_etag_cache
)
end
end
private
def
resource_weight_changes
@weight_changes
||=
resources
.
map
do
|
resource
|
changes
=
[]
base_data
=
{
user_id:
user
.
id
,
issue_id:
resource
.
id
}
changes
<<
base_data
.
merge
({
weight:
resource
.
previous_weight
,
created_at:
resource
.
previous_updated_at
})
if
resource
.
first_weight_event?
changes
<<
base_data
.
merge
({
weight:
resource
.
weight
,
created_at:
event_created_at
})
end
.
flatten
end
end
end
ee/spec/requests/api/issues_spec.rb
View file @
1b3f0d30
...
...
@@ -423,24 +423,6 @@ RSpec.describe API::Issues, :mailer do
expect
(
issue
.
reload
.
read_attribute
(
:weight
)).
to
be_nil
end
end
context
'when issue weight tracking feature flag is not active'
do
before
do
stub_feature_flags
(
track_issue_weight_change_events:
false
)
end
it
'does not create a ResourceWeightEvent'
do
expect
do
put
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
"
,
user
),
params:
{
weight:
9
}
end
.
not_to
change
{
ResourceWeightEvent
.
count
}
end
it
'creates a system note'
do
expect
do
put
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
"
,
user
),
params:
{
weight:
9
}
end
.
to
change
{
Note
.
count
}.
by
(
1
)
end
end
end
describe
'PUT /projects/:id/issues/:issue_id to update epic'
do
...
...
ee/spec/services/ee/issuable/common_system_notes_service_spec.rb
View file @
1b3f0d30
...
...
@@ -115,34 +115,12 @@ RSpec.describe Issuable::CommonSystemNotesService do
issuable
.
update
(
weight:
5
,
health_status:
'at_risk'
)
end
context
'when resource weight event tracking is enabled'
do
before
do
stub_feature_flags
(
track_issue_weight_change_events:
true
)
end
it
'creates a resource weight event'
do
expect
{
subject
}.
to
change
{
ResourceWeightEvent
.
count
}
end
it
'does not create a system note'
do
expect
{
subject
}.
not_to
change
{
Note
.
count
}
end
it
'creates a resource weight event'
do
expect
{
subject
}.
to
change
{
ResourceWeightEvent
.
count
}
end
context
'when resource weight event tracking is disabled'
do
before
do
stub_feature_flags
(
track_issue_weight_change_events:
false
)
end
it
'does not created a resource weight event'
do
expect
{
subject
}.
not_to
change
{
ResourceWeightEvent
.
count
}
end
it
'does create a system note'
do
expect
{
subject
}.
to
change
{
Note
.
count
}.
from
(
0
).
to
(
1
)
expect
(
Note
.
first
.
note
).
to
eq
(
'changed weight to **5**'
)
end
it
'does not create a system note'
do
expect
{
subject
}.
not_to
change
{
Note
.
count
}
end
it_behaves_like
'issuable iteration changed'
...
...
ee/spec/services/ee/system_notes/issuables_service_spec.rb
View file @
1b3f0d30
...
...
@@ -13,36 +13,6 @@ RSpec.describe ::SystemNotes::IssuablesService do
let
(
:service
)
{
described_class
.
new
(
noteable:
noteable
,
project:
project
,
author:
author
)
}
describe
'#change_weight_note'
do
context
'when weight changed'
do
let
(
:noteable
)
{
create
(
:issue
,
project:
project
,
title:
'Lorem ipsum'
,
weight:
4
)
}
subject
{
service
.
change_weight_note
}
it_behaves_like
'a system note'
do
let
(
:action
)
{
'weight'
}
end
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"changed weight to **4**"
end
end
context
'when weight removed'
do
let
(
:noteable
)
{
create
(
:issue
,
project:
project
,
title:
'Lorem ipsum'
,
weight:
nil
)
}
subject
{
service
.
change_weight_note
}
it_behaves_like
'a system note'
do
let
(
:action
)
{
'weight'
}
end
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
'removed the weight'
end
end
end
describe
'#change_health_status_note'
do
context
'when health_status changed'
do
let
(
:noteable
)
{
create
(
:issue
,
project:
project
,
title:
'Lorem ipsum'
,
health_status:
'at_risk'
)
}
...
...
ee/spec/services/
ee/
resource_events/change_weight_service_spec.rb
→
ee/spec/services/resource_events/change_weight_service_spec.rb
View file @
1b3f0d30
...
...
@@ -2,7 +2,7 @@
require
'spec_helper'
RSpec
.
describe
EE
::
ResourceEvents
::
ChangeWeightService
do
RSpec
.
describe
ResourceEvents
::
ChangeWeightService
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let
(
:issue
)
{
create
(
:issue
,
weight:
3
)
}
...
...
@@ -35,7 +35,7 @@ RSpec.describe EE::ResourceEvents::ChangeWeightService do
context
'when there is no existing weight event record'
do
before
do
ResourceWeightEvent
.
delete_all
issue
.
update
(
weight:
5
,
updated_at:
10
.
seconds
.
ago
)
issue
.
update
!
(
weight:
5
,
updated_at:
10
.
seconds
.
ago
)
end
it
'creates the expected event records'
do
...
...
ee/spec/services/system_note_service_spec.rb
View file @
1b3f0d30
...
...
@@ -14,16 +14,6 @@ RSpec.describe SystemNoteService do
let_it_be
(
:issue
)
{
noteable
}
let_it_be
(
:epic
)
{
create
(
:epic
,
group:
group
)
}
describe
'.change_weight_note'
do
it
'calls IssuableService'
do
expect_next_instance_of
(
::
SystemNotes
::
IssuablesService
)
do
|
service
|
expect
(
service
).
to
receive
(
:change_weight_note
)
end
described_class
.
change_weight_note
(
noteable
,
project
,
author
)
end
end
describe
'.change_health_status_note'
do
it
'calls IssuableService'
do
expect_next_instance_of
(
::
SystemNotes
::
IssuablesService
)
do
|
service
|
...
...
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