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
244fb0d9
Commit
244fb0d9
authored
Sep 14, 2020
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix subscription seats update
Skip those without namespace and report to sentry
parent
f2982a31
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
0 deletions
+42
-0
changelogs/unreleased/249040-fix-subscription-without-namespace.yml
.../unreleased/249040-fix-subscription-without-namespace.yml
+5
-0
ee/app/workers/update_max_seats_used_for_gitlab_com_subscriptions_worker.rb
...ate_max_seats_used_for_gitlab_com_subscriptions_worker.rb
+15
-0
ee/spec/workers/update_max_seats_used_for_gitlab_com_subscriptions_worker_spec.rb
...ax_seats_used_for_gitlab_com_subscriptions_worker_spec.rb
+22
-0
No files found.
changelogs/unreleased/249040-fix-subscription-without-namespace.yml
0 → 100644
View file @
244fb0d9
---
title
:
Fix max seats used not updated in billing summary
merge_request
:
42184
author
:
type
:
fixed
ee/app/workers/update_max_seats_used_for_gitlab_com_subscriptions_worker.rb
View file @
244fb0d9
...
...
@@ -16,6 +16,11 @@ class UpdateMaxSeatsUsedForGitlabComSubscriptionsWorker # rubocop:disable Scalab
tuples
=
[]
subscriptions
.
each
do
|
subscription
|
unless
subscription
.
namespace
track_error
(
subscription
)
next
end
subscription
.
refresh_seat_attributes!
tuples
<<
[
subscription
.
id
,
subscription
.
max_seats_used
,
subscription
.
seats_in_use
,
subscription
.
seats_owed
]
...
...
@@ -33,4 +38,14 @@ class UpdateMaxSeatsUsedForGitlabComSubscriptionsWorker # rubocop:disable Scalab
end
end
end
private
def
track_error
(
subscription
)
Gitlab
::
ErrorTracking
.
track_exception
(
StandardError
.
new
(
'Namespace absent'
),
gitlab_subscription_id:
subscription
.
id
,
namespace_id:
subscription
.
namespace_id
)
end
end
ee/spec/workers/update_max_seats_used_for_gitlab_com_subscriptions_worker_spec.rb
View file @
244fb0d9
...
...
@@ -103,6 +103,28 @@ RSpec.describe UpdateMaxSeatsUsedForGitlabComSubscriptionsWorker do
.
and
change
(
gitlab_subscription_2
,
:seats_in_use
).
from
(
0
).
to
(
13
)
.
and
change
(
gitlab_subscription_2
,
:seats_owed
).
from
(
0
).
to
(
12
)
end
context
'when namespace is absent'
do
before
do
gitlab_subscription
.
update!
(
namespace_id:
nil
)
end
it
'skips the subscription'
do
expect
(
Gitlab
::
ErrorTracking
).
to
receive
(
:track_exception
).
with
(
an_instance_of
(
StandardError
),
{
gitlab_subscription_id:
gitlab_subscription
.
id
,
namespace_id:
nil
}
)
expect
do
perform_and_reload
end
.
to
not_change
(
gitlab_subscription
,
:max_seats_used
).
from
(
0
)
.
and
not_change
(
gitlab_subscription
,
:seats_in_use
).
from
(
0
)
.
and
not_change
(
gitlab_subscription
,
:seats_owed
).
from
(
0
)
.
and
change
(
gitlab_subscription_2
,
:max_seats_used
).
from
(
0
).
to
(
14
)
.
and
change
(
gitlab_subscription_2
,
:seats_in_use
).
from
(
0
).
to
(
13
)
.
and
change
(
gitlab_subscription_2
,
:seats_owed
).
from
(
0
).
to
(
12
)
end
end
end
end
end
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