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
7d26bf16
Commit
7d26bf16
authored
Jul 08, 2021
by
Allison Browne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move email notification into UpdateBuildMinutes
parent
e2d2bbcc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
6 deletions
+33
-6
ee/app/models/ee/ci/build.rb
ee/app/models/ee/ci/build.rb
+0
-3
ee/app/services/ci/minutes/update_build_minutes_service.rb
ee/app/services/ci/minutes/update_build_minutes_service.rb
+7
-0
ee/app/workers/ee/build_finished_worker.rb
ee/app/workers/ee/build_finished_worker.rb
+0
-3
ee/spec/services/ci/minutes/update_build_minutes_service_spec.rb
.../services/ci/minutes/update_build_minutes_service_spec.rb
+26
-0
No files found.
ee/app/models/ee/ci/build.rb
View file @
7d26bf16
...
...
@@ -56,9 +56,6 @@ module EE
# This will ensure consumption is calculated before related records are deleted.
if
::
Feature
.
enabled?
(
:cancel_pipelines_prior_to_destroy
,
default_enabled: :yaml
)
::
Ci
::
Minutes
::
UpdateBuildMinutesService
.
new
(
build
.
project
,
nil
).
execute
(
build
)
# We need to use `reset` on `project` because their AR associations have been cached
# and `Namespace#namespace_statistics` will return stale data.
::
Ci
::
Minutes
::
EmailNotificationService
.
new
(
build
.
project
.
reset
).
execute
if
::
Gitlab
.
com?
end
end
end
...
...
ee/app/services/ci/minutes/update_build_minutes_service.rb
View file @
7d26bf16
...
...
@@ -17,11 +17,18 @@ module Ci
track_usage_of_monthly_minutes
(
consumption
)
send_minutes_email_notification
compare_with_live_consumption
(
build
,
consumption
)
end
private
def
send_minutes_email_notification
# `perform reset` on `project` because otherwise `Namespace#namespace_statistics` will return stale data.
::
Ci
::
Minutes
::
EmailNotificationService
.
new
(
@project
.
reset
).
execute
if
::
Gitlab
.
com?
end
def
legacy_track_usage_of_monthly_minutes
(
consumption
)
ProjectStatistics
.
update_counters
(
project_statistics
,
shared_runners_seconds:
consumption
)
...
...
ee/app/workers/ee/build_finished_worker.rb
View file @
7d26bf16
...
...
@@ -5,9 +5,6 @@ module EE
def
process_build
(
build
)
unless
::
Feature
.
enabled?
(
:cancel_pipelines_prior_to_destroy
,
default_enabled: :yaml
)
::
Ci
::
Minutes
::
UpdateBuildMinutesService
.
new
(
build
.
project
,
nil
).
execute
(
build
)
# We need to use `reset` on `project` because their AR associations have been cached
# and `Namespace#namespace_statistics` will return stale data.
::
Ci
::
Minutes
::
EmailNotificationService
.
new
(
build
.
project
.
reset
).
execute
if
::
Gitlab
.
com?
end
RequirementsManagement
::
ProcessRequirementsReportsWorker
.
perform_async
(
build
.
id
)
...
...
ee/spec/services/ci/minutes/update_build_minutes_service_spec.rb
View file @
7d26bf16
...
...
@@ -54,6 +54,32 @@ RSpec.describe Ci::Minutes::UpdateBuildMinutesService do
it_behaves_like
'new tracking matches legacy tracking'
context
'when on .com'
do
before
do
allow
(
Gitlab
).
to
receive
(
:com?
).
and_return
(
true
)
end
it
'sends an email'
do
expect_next_instance_of
(
Ci
::
Minutes
::
EmailNotificationService
)
do
|
service
|
expect
(
service
).
to
receive
(
:execute
)
end
subject
end
end
context
'when not on .com'
do
before
do
allow
(
Gitlab
).
to
receive
(
:com?
).
and_return
(
false
)
end
it
'does not send an email'
do
expect
(
Ci
::
Minutes
::
EmailNotificationService
).
not_to
receive
(
:new
)
subject
end
end
context
'when feature flag ci_minutes_monthly_tracking is disabled'
do
before
do
stub_feature_flags
(
ci_minutes_monthly_tracking:
false
)
...
...
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