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
0dd20200
Commit
0dd20200
authored
Feb 06, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement billing_enabled change counter
parent
ee8e5a59
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
app/workers/check_gcp_project_billing_worker.rb
app/workers/check_gcp_project_billing_worker.rb
+21
-0
No files found.
app/workers/check_gcp_project_billing_worker.rb
View file @
0dd20200
...
...
@@ -34,6 +34,9 @@ class CheckGcpProjectBillingWorker
return
unless
try_obtain_lease_for
(
token
)
billing_enabled_projects
=
CheckGcpProjectBillingService
.
new
.
execute
(
token
)
update_billing_change_counter
(
check_previous_state
(
token
),
!
billing_enabled_projects
.
empty?
)
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
redis
.
set
(
self
.
class
.
redis_shared_state_key_for
(
token
),
!
billing_enabled_projects
.
empty?
,
...
...
@@ -51,9 +54,27 @@ class CheckGcpProjectBillingWorker
"gitlab:gcp:session:
#{
token_key
}
"
end
def
self
.
redis_billing_change_key
"gitlab:gcp:billing_enabled_changes"
end
def
try_obtain_lease_for
(
token
)
Gitlab
::
ExclusiveLease
.
new
(
"check_gcp_project_billing_worker:
#{
token
.
hash
}
"
,
timeout:
LEASE_TIMEOUT
)
.
try_obtain
end
def
check_previous_state
(
token
)
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
redis
.
get
(
self
.
class
.
redis_shared_state_key_for
(
token
))
end
end
def
update_billing_change_counter
(
previous_state
,
current_state
)
return
unless
previous_state
==
'false'
&&
current_state
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
redis
.
incr
(
self
.
class
.
redis_billing_change_key
)
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