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
0ccb6aa0
Commit
0ccb6aa0
authored
Mar 09, 2021
by
Vijay Hawoldar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate GitlabSubscriptions module from class name
To be consistent with other module definitions
parent
effa7178
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
48 deletions
+50
-48
ee/app/services/gitlab_subscriptions/fetch_subscription_plans_service.rb
.../gitlab_subscriptions/fetch_subscription_plans_service.rb
+50
-48
No files found.
ee/app/services/gitlab_subscriptions/fetch_subscription_plans_service.rb
View file @
0ccb6aa0
# frozen_string_literal: true
class
GitlabSubscriptions::FetchSubscriptionPlansService
URL
=
"
#{
EE
::
SUBSCRIPTIONS_URL
}
/gitlab_plans"
.
freeze
module
GitlabSubscriptions
class
FetchSubscriptionPlansService
URL
=
"
#{
EE
::
SUBSCRIPTIONS_URL
}
/gitlab_plans"
.
freeze
def
initialize
(
plan
:,
namespace_id:
nil
)
@plan
=
plan
@namespace_id
=
namespace_id
end
def
execute
cached
{
send_request
}
end
def
initialize
(
plan
:,
namespace_id:
nil
)
@plan
=
plan
@namespace_id
=
namespace_id
end
private
def
execute
cached
{
send_request
}
end
def
send_request
response
=
Gitlab
::
HTTP
.
get
(
URL
,
allow_local_requests:
true
,
query:
{
plan:
@plan
,
namespace_id:
@namespace_id
},
headers:
{
'Accept'
=>
'application/json'
}
)
private
Gitlab
::
Json
.
parse
(
response
.
body
).
map
{
|
plan
|
Hashie
::
Mash
.
new
(
plan
)
}
rescue
=>
e
Gitlab
::
AppLogger
.
info
"Unable to connect to GitLab Customers App
#{
e
}
"
def
send_request
response
=
Gitlab
::
HTTP
.
get
(
URL
,
allow_local_requests:
true
,
query:
{
plan:
@plan
,
namespace_id:
@namespace_id
},
headers:
{
'Accept'
=>
'application/json'
}
)
nil
end
Gitlab
::
Json
.
parse
(
response
.
body
).
map
{
|
plan
|
Hashie
::
Mash
.
new
(
plan
)
}
rescue
=>
e
Gitlab
::
AppLogger
.
info
"Unable to connect to GitLab Customers App
#{
e
}
"
def
cached
if
plans_data
=
cache
.
read
(
cache_key
)
plans_data
else
cache
.
fetch
(
cache_key
,
force:
true
,
expires_in:
1
.
day
)
{
yield
}
nil
end
end
def
cache
Rails
.
cache
end
def
cache_key
if
Feature
.
enabled?
(
:pnp_subscription_plan_cache_key
)
if
@namespace_id
.
present?
"pnp-subscription-plan-
#{
@plan
}
-
#{
@namespace_id
}
"
else
"pnp-subscription-plan-
#{
@plan
}
"
end
elsif
Feature
.
enabled?
(
:subscription_plan_cache_key
)
if
@namespace_id
.
present?
"subscription-plan-
#{
@plan
}
-
#{
@namespace_id
}
"
def
cached
if
plans_data
=
cache
.
read
(
cache_key
)
plans_data
else
"subscription-plan-
#{
@plan
}
"
cache
.
fetch
(
cache_key
,
force:
true
,
expires_in:
1
.
day
)
{
yield
}
end
else
if
@namespace_id
.
present?
"subscription-plans-
#{
@plan
}
-
#{
@namespace_id
}
"
end
def
cache
Rails
.
cache
end
def
cache_key
if
Feature
.
enabled?
(
:pnp_subscription_plan_cache_key
)
if
@namespace_id
.
present?
"pnp-subscription-plan-
#{
@plan
}
-
#{
@namespace_id
}
"
else
"pnp-subscription-plan-
#{
@plan
}
"
end
elsif
Feature
.
enabled?
(
:subscription_plan_cache_key
)
if
@namespace_id
.
present?
"subscription-plan-
#{
@plan
}
-
#{
@namespace_id
}
"
else
"subscription-plan-
#{
@plan
}
"
end
else
"subscription-plans-
#{
@plan
}
"
if
@namespace_id
.
present?
"subscription-plans-
#{
@plan
}
-
#{
@namespace_id
}
"
else
"subscription-plans-
#{
@plan
}
"
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