app_manager 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/controllers/app_manager/plans_controller.rb +1 -0
- data/lib/app_manager/model.rb +42 -6
- data/lib/app_manager/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 332f708479d365509b91a40229d7be81e2d4ff29bc14ec4d24f59cad3dd007d8
|
|
4
|
+
data.tar.gz: addf31453c0847a80a734994ec65d8eaa8eb9a8bf18067359e3e97c5cbd06ac6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cafc22adef5875aea99cc8f8acebc7ee79e187359bf7aa6408d1692390a79af37e721efe3e7fd7a3a23e898b092988eca098a0ce6d3f737cfae30ceb19422243
|
|
7
|
+
data.tar.gz: d74683f76df315f6a9b03f3f357d09ef63d50f0efd18b64e7fd83a160603cc26078ab82fc1d2c0041772de37f656714f554ac83656514cbd59a2c25220e2efc8
|
data/Gemfile.lock
CHANGED
data/lib/app_manager/model.rb
CHANGED
|
@@ -2,7 +2,8 @@ module AppManager
|
|
|
2
2
|
module Model
|
|
3
3
|
extend ActiveSupport::Concern
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
@@remaining_cache_key = "get_remaining_days_key"
|
|
6
|
+
@@get_charge_key = "get_charge_key"
|
|
6
7
|
|
|
7
8
|
def has_plan
|
|
8
9
|
if !self[AppManager.configuration.plan_id_or_name_field]
|
|
@@ -16,14 +17,15 @@ module AppManager
|
|
|
16
17
|
Rails.logger.info "Plan id found nil or not set"
|
|
17
18
|
return false;
|
|
18
19
|
end
|
|
19
|
-
remaining_days =
|
|
20
|
+
remaining_days = fetch_static_remaining_days
|
|
20
21
|
if remaining_days > 0
|
|
21
22
|
return true
|
|
22
23
|
end
|
|
23
|
-
plan_obj = AppManager::Client.new
|
|
24
|
-
shop_domain = self[AppManager.configuration.shopify_domain_field]
|
|
25
|
-
active_charge = plan_obj.get_charge(shop_domain) rescue nil
|
|
26
|
-
|
|
24
|
+
# plan_obj = AppManager::Client.new
|
|
25
|
+
# shop_domain = self[AppManager.configuration.shopify_domain_field]
|
|
26
|
+
# active_charge = plan_obj.get_charge(shop_domain) rescue nil
|
|
27
|
+
active_charge = fetch_static_get_charge
|
|
28
|
+
return active_charge && active_charge['active_charge'].present? && !active_charge['active_charge'].nil? ? true : false
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
|
|
@@ -195,6 +197,40 @@ module AppManager
|
|
|
195
197
|
|
|
196
198
|
|
|
197
199
|
|
|
200
|
+
def fetch_static_remaining_days
|
|
201
|
+
@remaining_cache_key = "app-manager-cache/#{self.shopify_domain}-remaining_days"
|
|
202
|
+
if fetch_cached_static_remaining_days(@remaining_cache_key).present?
|
|
203
|
+
return fetch_cached_static_remaining_days(@remaining_cache_key)
|
|
204
|
+
end
|
|
205
|
+
remaining_days = self.get_remaining_days
|
|
206
|
+
Rails.cache.write(@remaining_cache_key, remaining_days, expires_in: AppManager.configuration.expires_in)
|
|
207
|
+
return remaining_days
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def fetch_cached_static_remaining_days(cache_key)
|
|
211
|
+
if Rails.cache.read(cache_key).present?
|
|
212
|
+
return Rails.cache.read(cache_key)
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def fetch_static_get_charge
|
|
218
|
+
@get_charge_key = "app-manager-cache/#{self.shopify_domain}-get_charge"
|
|
219
|
+
if fetch_cached_static_get_charge(@get_charge_key).present?
|
|
220
|
+
return fetch_cached_static_get_charge(@get_charge_key)
|
|
221
|
+
end
|
|
222
|
+
charge = self.get_charge
|
|
223
|
+
Rails.cache.write(@get_charge_key, charge, expires_in: AppManager.configuration.expires_in)
|
|
224
|
+
return charge
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
def fetch_cached_static_get_charge(cache_key)
|
|
228
|
+
if Rails.cache.read(cache_key).present?
|
|
229
|
+
return Rails.cache.read(cache_key)
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
|
|
198
234
|
private
|
|
199
235
|
|
|
200
236
|
def casted_value(value,value_type)
|
data/lib/app_manager/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: app_manager
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.2.
|
|
4
|
+
version: 1.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hulkapps
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-07-
|
|
11
|
+
date: 2022-07-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: httparty
|