app_manager 2.4.3 → 2.4.5
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 +5 -5
- data/app/controllers/app_manager/plans_controller.rb +8 -5
- data/lib/app_manager/fail_safe.rb +10 -8
- data/lib/app_manager/fail_safe_helper.rb +33 -0
- data/lib/app_manager/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 94638c960cf4212bf79630b801d43959ed6b59b1b4f5ff29904a040deb1f9b52
|
|
4
|
+
data.tar.gz: f33a5c3a6982758993bbc11ccc0cc62b5da051994420a75fdbf471771bd88a7c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b7b5b23ba4794bf59faa9e333cc2ebb5ea9d52afc37961a36ddfed603ce4bc0da0831c3a6cb7745f6d4be556c988aa35e7c72a3f23f859a4fde5cd7d975af927
|
|
7
|
+
data.tar.gz: 485ad091b4a35194d6118e2264223b3d4066fb29c917b20696ed7f40c8c6017e024bdee9129e38e1f08ec68dddf93025bb9a76d0257bcdd3870d4297ae78c919
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
app_manager (2.4.
|
|
4
|
+
app_manager (2.4.5)
|
|
5
5
|
activerecord-import (~> 1.4)
|
|
6
6
|
httparty
|
|
7
7
|
kaminari (>= 0.16.3)
|
|
@@ -10,7 +10,7 @@ PATH
|
|
|
10
10
|
GEM
|
|
11
11
|
remote: https://rubygems.org/
|
|
12
12
|
specs:
|
|
13
|
-
action_text-trix (2.1.
|
|
13
|
+
action_text-trix (2.1.17)
|
|
14
14
|
railties
|
|
15
15
|
actioncable (8.1.2)
|
|
16
16
|
actionpack (= 8.1.2)
|
|
@@ -120,7 +120,7 @@ GEM
|
|
|
120
120
|
prism (>= 1.3.0)
|
|
121
121
|
rdoc (>= 4.0.0)
|
|
122
122
|
reline (>= 0.4.2)
|
|
123
|
-
json (2.
|
|
123
|
+
json (2.19.2)
|
|
124
124
|
kaminari (1.2.2)
|
|
125
125
|
activesupport (>= 4.1.0)
|
|
126
126
|
kaminari-actionview (= 1.2.2)
|
|
@@ -134,7 +134,7 @@ GEM
|
|
|
134
134
|
kaminari-core (= 1.2.2)
|
|
135
135
|
kaminari-core (1.2.2)
|
|
136
136
|
logger (1.7.0)
|
|
137
|
-
loofah (2.25.
|
|
137
|
+
loofah (2.25.1)
|
|
138
138
|
crass (~> 1.0.2)
|
|
139
139
|
nokogiri (>= 1.12.0)
|
|
140
140
|
mail (2.9.0)
|
|
@@ -244,7 +244,7 @@ GEM
|
|
|
244
244
|
securerandom (0.4.1)
|
|
245
245
|
stringio (3.2.0)
|
|
246
246
|
thor (1.5.0)
|
|
247
|
-
timeout (0.6.
|
|
247
|
+
timeout (0.6.1)
|
|
248
248
|
tsort (0.2.0)
|
|
249
249
|
tzinfo (2.0.6)
|
|
250
250
|
concurrent-ruby (~> 1.0)
|
|
@@ -6,6 +6,7 @@ module AppManager
|
|
|
6
6
|
cache_response_for :index
|
|
7
7
|
cache_response_for :users
|
|
8
8
|
skip_before_action :verify_authenticity_token, :only => [:active_without_plan, :burst_cache, :fail_safe_backup]
|
|
9
|
+
ALLOWED_SORTS = %w[name shopify_email created_at].freeze
|
|
9
10
|
|
|
10
11
|
def index
|
|
11
12
|
render :json => {"features" => AppManager.configuration.plan_features || []}
|
|
@@ -110,8 +111,10 @@ module AppManager
|
|
|
110
111
|
if model
|
|
111
112
|
|
|
112
113
|
search = params[:search]
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
sort_param = params[:sort]&.downcase
|
|
115
|
+
sort = ALLOWED_SORTS.include?(sort_param) ? AppManager.configuration.field_names[sort_param] : 'created_at'
|
|
116
|
+
order_param = params[:order]&.downcase
|
|
117
|
+
order = %w[asc desc].include?(order_param) ? order_param : 'asc'
|
|
115
118
|
plans = params[:plans] || nil
|
|
116
119
|
plans = plans.values if !plans.nil?
|
|
117
120
|
shopify_plans = params[:shopify_plans] || nil
|
|
@@ -120,12 +123,12 @@ module AppManager
|
|
|
120
123
|
@shopify_email = AppManager.configuration.field_names['shopify_email']
|
|
121
124
|
@shopify_plan_name_field = AppManager.configuration.field_names['shopify_plan']
|
|
122
125
|
if params[:search]
|
|
123
|
-
data = model.where("#{@shopify_domain} LIKE :search OR #{@shopify_email} LIKE :search", search: "%#{search}%").order(sort
|
|
126
|
+
data = model.where("#{@shopify_domain} LIKE :search OR #{@shopify_email} LIKE :search", search: "%#{search}%").order(sort => order)
|
|
124
127
|
data = data.where(@plan_field => plans) if !plans.nil?
|
|
125
128
|
data = data.where(@shopify_plan_name_field => shopify_plans) if !shopify_plans.nil?
|
|
126
129
|
data = data.page(params[:page]).per(items_per_page)
|
|
127
130
|
else
|
|
128
|
-
data = model.order(sort
|
|
131
|
+
data = model.order(sort => order)
|
|
129
132
|
data = data.where(@plan_field => plans) if !plans.nil?
|
|
130
133
|
data = data.where(@shopify_plan_name_field => shopify_plans) if !shopify_plans.nil?
|
|
131
134
|
data = data.page(params[:page]).per(items_per_page)
|
|
@@ -133,7 +136,7 @@ module AppManager
|
|
|
133
136
|
all_user_count = model.count
|
|
134
137
|
users = {
|
|
135
138
|
"current_page" => data && data.current_page ? data.current_page : 0,
|
|
136
|
-
"data" => data ? data.collect { |st| @field_names.map { |key, value| [key, "#{st[value]}"] }.to_h } : [],
|
|
139
|
+
"data" => data ? data.collect { |st| @field_names.except('shopify_token').map { |key, value| [key, "#{st[value]}"] }.to_h } : [],
|
|
137
140
|
"first_page_url" => "#{app_url}/api/app-manager/users?page=1",
|
|
138
141
|
"from" => data && data.total_pages ? data.current_page == 1 ? 1 : ((data.current_page-1)*items_per_page)+1 : 0,
|
|
139
142
|
"last_page" => data && data.total_pages ? data.total_pages : 0,
|
|
@@ -4,9 +4,11 @@ require 'time'
|
|
|
4
4
|
require "fileutils"
|
|
5
5
|
require 'active_record'
|
|
6
6
|
require 'activerecord-import'
|
|
7
|
+
require_relative 'fail_safe_helper'
|
|
7
8
|
module AppManager
|
|
8
9
|
|
|
9
10
|
class FailSafe
|
|
11
|
+
include AppManager::FailSafeHelper
|
|
10
12
|
|
|
11
13
|
def initialize(db_name = 'app_manager_local')
|
|
12
14
|
# begin
|
|
@@ -321,7 +323,7 @@ module AppManager
|
|
|
321
323
|
app_structure = AppManager::AppStructure.first
|
|
322
324
|
app_structure_computed = {}
|
|
323
325
|
if app_structure.present?
|
|
324
|
-
app_structure_computed["banners"] =
|
|
326
|
+
app_structure_computed["banners"] = safe_parse_json(app_structure.banners)
|
|
325
327
|
end
|
|
326
328
|
return app_structure_computed
|
|
327
329
|
end
|
|
@@ -374,20 +376,20 @@ module AppManager
|
|
|
374
376
|
new_plan = {}
|
|
375
377
|
plan.as_json.each_with_index do |(key, value)|
|
|
376
378
|
if ['interval'].include?(key)
|
|
377
|
-
val =
|
|
379
|
+
val = safe_parse_json(value)
|
|
378
380
|
new_plan[key] = val
|
|
379
381
|
new_plan[key] = val['value'] if val rescue {}
|
|
380
382
|
elsif ['shopify_plans'].include?(key)
|
|
381
|
-
val =
|
|
383
|
+
val = safe_parse_json(value)
|
|
382
384
|
new_plan[key] = val.collect { |e| e['value'] }
|
|
383
385
|
elsif ['affiliate'].include?(key)
|
|
384
|
-
new_plan[key] =
|
|
386
|
+
new_plan[key] = safe_parse_json(value)
|
|
385
387
|
elsif ['is_custom', 'public', 'store_base_plan', 'choose_later_plan'].include?(key)
|
|
386
388
|
new_plan[key] = (value == 0 || value == false ? false : true)
|
|
387
389
|
elsif ['test'].include?(key)
|
|
388
390
|
new_plan[key] = (value == 0 || value == false ? nil : true)
|
|
389
391
|
elsif ['features'].include?(key)
|
|
390
|
-
value =
|
|
392
|
+
value = safe_parse_json(value)
|
|
391
393
|
value = value.each { |e| e.delete("id") }.each { |e| e.delete("created_at") }.each { |e| e.delete("updated_at") }
|
|
392
394
|
new_plan[key] = value
|
|
393
395
|
elsif ['plan_id'].include?(key)
|
|
@@ -473,10 +475,10 @@ module AppManager
|
|
|
473
475
|
new_plan = {}
|
|
474
476
|
plan.as_json.each_with_index do |(key, value), index|
|
|
475
477
|
if ['interval'].include?(key)
|
|
476
|
-
val =
|
|
478
|
+
val = safe_parse_json(value)
|
|
477
479
|
new_plan[key] = val
|
|
478
480
|
elsif ['shopify_plans', 'affiliate', 'features'].include?(key)
|
|
479
|
-
new_plan[key] =
|
|
481
|
+
new_plan[key] = safe_parse_json(value)
|
|
480
482
|
elsif ['is_custom', 'public', 'store_base_plan', 'choose_later_plan'].include?(key)
|
|
481
483
|
new_plan[key] = (value == 0 || value == false ? false : true)
|
|
482
484
|
elsif ['test'].include?(key)
|
|
@@ -678,7 +680,7 @@ module AppManager
|
|
|
678
680
|
message = {"message" => 'fail'}
|
|
679
681
|
if options
|
|
680
682
|
options.gsub!('null', 'nil') rescue nil
|
|
681
|
-
charge =
|
|
683
|
+
charge = safe_parse_json(options)
|
|
682
684
|
if charge
|
|
683
685
|
charge = charge.as_json if charge.class == Hash
|
|
684
686
|
test_value = charge["test"]
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module AppManager
|
|
2
|
+
module FailSafeHelper
|
|
3
|
+
def convert_ruby_hash_to_json(ruby_string)
|
|
4
|
+
return nil if ruby_string.nil? || ruby_string.empty?
|
|
5
|
+
|
|
6
|
+
json_string = ruby_string.dup
|
|
7
|
+
|
|
8
|
+
json_string.gsub!(/([^:])=>([^:])/, '\1:\2')
|
|
9
|
+
|
|
10
|
+
json_string.gsub!(/\bnil\b/, 'null')
|
|
11
|
+
|
|
12
|
+
json_string.gsub!(/\btrue\b/, 'true')
|
|
13
|
+
json_string.gsub!(/\bfalse\b/, 'false')
|
|
14
|
+
|
|
15
|
+
json_string.gsub!(/,(\s*[}\]])/, '\1')
|
|
16
|
+
|
|
17
|
+
json_string
|
|
18
|
+
rescue => e
|
|
19
|
+
nil
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def safe_parse_json(value)
|
|
23
|
+
return nil if value.nil? || value.empty?
|
|
24
|
+
|
|
25
|
+
begin
|
|
26
|
+
json_string = convert_ruby_hash_to_json(value)
|
|
27
|
+
return JSON.parse(json_string) if json_string
|
|
28
|
+
rescue JSON::ParserError => e
|
|
29
|
+
return nil
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
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: 2.4.
|
|
4
|
+
version: 2.4.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rahul Tiwari @ Hulkapps
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-03-
|
|
11
|
+
date: 2026-03-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: httparty
|
|
@@ -114,6 +114,7 @@ files:
|
|
|
114
114
|
- lib/app_manager/engine.rb
|
|
115
115
|
- lib/app_manager/exceptions.rb
|
|
116
116
|
- lib/app_manager/fail_safe.rb
|
|
117
|
+
- lib/app_manager/fail_safe_helper.rb
|
|
117
118
|
- lib/app_manager/graphql_helper.rb
|
|
118
119
|
- lib/app_manager/model.rb
|
|
119
120
|
- lib/app_manager/protection.rb
|
|
@@ -147,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
147
148
|
- !ruby/object:Gem::Version
|
|
148
149
|
version: '0'
|
|
149
150
|
requirements: []
|
|
150
|
-
rubygems_version: 3.
|
|
151
|
+
rubygems_version: 3.5.13
|
|
151
152
|
signing_key:
|
|
152
153
|
specification_version: 4
|
|
153
154
|
summary: An API wrapper of Hulkapps AppManager portal
|