app_manager 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/controllers/app_manager/plans_controller.rb +18 -3
- data/lib/app_manager/client/connection.rb +3 -3
- data/lib/app_manager/fail_safe.rb +43 -8
- data/lib/app_manager/model.rb +1 -1
- 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: 49314ece09cae0fc0ff0215616397c7d3a46fd9ff962b7b2c67c2a4894170ab9
|
4
|
+
data.tar.gz: eab49d56c31b7b21a8c545b2179d2f1dc1369ca90dbb422b36f911073740d233
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3984d372c6fb85033b6a2945718424866ac36e92fa5c7de542b703bf4e5bcadc969b1a456e4f68f17cde123c310f18de57e512a8817f568a7f6e30f44efc522
|
7
|
+
data.tar.gz: 4b8210b8595f1efc87bb78910556a78f43f065c35019fc07c330b52c7e2dedd63ba901812bd758156191078d8b5be7e76a83fe07fecfcbe5eb82d789a16e22bc
|
data/Gemfile.lock
CHANGED
@@ -70,12 +70,27 @@ module AppManager
|
|
70
70
|
|
71
71
|
def users
|
72
72
|
if model
|
73
|
-
|
73
|
+
|
74
74
|
search = params[:search]
|
75
|
+
sort = params[:sort] || AppManager.configuration.field_names['created_at']
|
76
|
+
order = params[:order] || 'asc'
|
77
|
+
plans = params[:plans] || nil
|
78
|
+
plans = plans.values if !plans.nil?
|
79
|
+
shopify_plans = params[:shopify_plans] || nil
|
80
|
+
shopify_plans = shopify_plans.values if !shopify_plans.nil?
|
81
|
+
items_per_page = params[:itemsPerPage] || 25
|
75
82
|
@shopify_email = AppManager.configuration.field_names['shopify_email']
|
76
|
-
|
83
|
+
@shopify_plan_name_field = AppManager.configuration.field_names['shopify_plan']
|
84
|
+
data = model
|
85
|
+
if params[:search]
|
86
|
+
data = model.where("#{@shopify_domain} LIKE :search OR #{@shopify_email} LIKE :search", search: "%#{search}%")
|
87
|
+
data = data.where(@plan_field => plans) if !plans.nil?
|
88
|
+
data = data.where(@shopify_plan_name_field => shopify_plans) if !shopify_plans.nil?
|
89
|
+
data = data.page(params[:page]).per(items_per_page)
|
77
90
|
else
|
78
|
-
data = model.
|
91
|
+
data = model.where(@plan_field => plans) if !plans.nil?
|
92
|
+
data = data.where(@shopify_plan_name_field => shopify_plans) if !shopify_plans.nil?
|
93
|
+
data = data.page(params[:page]).per(items_per_page)
|
79
94
|
end
|
80
95
|
users = {
|
81
96
|
"current_page" => data && data.current_page ? data.current_page : 0,
|
@@ -60,9 +60,9 @@ module AppManager
|
|
60
60
|
@fs = AppManager::FailSafe.new
|
61
61
|
case path
|
62
62
|
when "static-contents"
|
63
|
-
return @fs.get_local_app_structures
|
63
|
+
return @fs.get_local_app_structures
|
64
64
|
when 'plans'
|
65
|
-
return @fs.get_local_plans(params)
|
65
|
+
return @fs.get_local_plans(params)
|
66
66
|
when 'plan'
|
67
67
|
return @fs.get_local_plan(params)
|
68
68
|
when 'store-charge'
|
@@ -70,7 +70,7 @@ module AppManager
|
|
70
70
|
when 'cancel-charge'
|
71
71
|
return @fs.store_cancel_charge(params,options)
|
72
72
|
when 'get-remaining-days'
|
73
|
-
return @fs.get_local_remaining_days(params,options)
|
73
|
+
return @fs.get_local_remaining_days(params,options)
|
74
74
|
when 'get-charge'
|
75
75
|
return @fs.get_local_charge(params,options)
|
76
76
|
else
|
@@ -8,6 +8,13 @@ module AppManager
|
|
8
8
|
def initialize(db_name='app_manager_local')
|
9
9
|
@apm_db = SQLite3::Database.open "db/#{db_name}.db"
|
10
10
|
@apm_db.results_as_hash = true
|
11
|
+
create_plan_table
|
12
|
+
create_charges_table
|
13
|
+
create_apps_table
|
14
|
+
create_app_structures_table
|
15
|
+
create_discount_plans_table
|
16
|
+
create_extend_trials_table
|
17
|
+
create_plan_users_table
|
11
18
|
end
|
12
19
|
|
13
20
|
def save_api_data(params)
|
@@ -50,7 +57,7 @@ module AppManager
|
|
50
57
|
|
51
58
|
def save_api_plans(plans)
|
52
59
|
@apm_db.execute("DROP TABLE IF EXISTS plans;")
|
53
|
-
|
60
|
+
create_plan_table
|
54
61
|
|
55
62
|
if plans.any?
|
56
63
|
plans.each do |plan|
|
@@ -75,7 +82,7 @@ module AppManager
|
|
75
82
|
|
76
83
|
def save_api_charges(charges)
|
77
84
|
@apm_db.execute("DROP TABLE IF EXISTS charges;")
|
78
|
-
|
85
|
+
create_charges_table
|
79
86
|
if charges.any?
|
80
87
|
charges.each do |charge|
|
81
88
|
charge_test = charge['test'] ? 1 : 0
|
@@ -87,7 +94,7 @@ module AppManager
|
|
87
94
|
|
88
95
|
def save_api_apps(apps)
|
89
96
|
@apm_db.execute("DROP TABLE IF EXISTS apps;")
|
90
|
-
|
97
|
+
create_apps_table
|
91
98
|
if apps.any?
|
92
99
|
apps.each do |app|
|
93
100
|
@apm_db.execute("INSERT INTO apps (id ,name ,slug ,url ,image ,api_token ,slack , created_at , updated_at ) VALUES (?,?,?,?,?,?,?,?,?)", app['id'],app['name'],app['slug'],app['url'],app['image'],app['api_token'],app['slack'],app['created_at'],app['updated_at'])
|
@@ -98,15 +105,15 @@ module AppManager
|
|
98
105
|
|
99
106
|
def save_api_app_structures(app_structures)
|
100
107
|
@apm_db.execute("DROP TABLE IF EXISTS app_structures;")
|
101
|
-
|
108
|
+
create_app_structures_table
|
102
109
|
if !app_structures.nil?
|
103
110
|
@apm_db.execute("INSERT INTO app_structures (banners) VALUES (?)", "#{app_structures.to_h}")
|
104
111
|
end
|
105
112
|
end
|
106
113
|
|
107
114
|
def save_api_discount_plans(discount_plans)
|
108
|
-
|
109
|
-
|
115
|
+
@apm_db.execute("DROP TABLE IF EXISTS discount_plans;")
|
116
|
+
create_discount_plans_table
|
110
117
|
if discount_plans.any?
|
111
118
|
discount_plans.each do |discount_plan|
|
112
119
|
@apm_db.execute("INSERT INTO discount_plans (id ,discount ,shop_domain ,cycle_count ,plan_id , created_by ,created_at ,updated_at ,app_id ,discount_type ) VALUES (?,?,?,?,?,?,?,?,?,?)", discount_plan['id'],discount_plan['discount'],discount_plan['shop_domain'],discount_plan['cycle_count'],discount_plan['plan_id'],discount_plan['created_by'],discount_plan['created_at'],discount_plan['updated_at'],discount_plan['app_id'],discount_plan['discount_type'])
|
@@ -116,7 +123,7 @@ module AppManager
|
|
116
123
|
|
117
124
|
def save_api_extend_trials(extend_trials)
|
118
125
|
@apm_db.execute("DROP TABLE IF EXISTS extend_trials;")
|
119
|
-
|
126
|
+
create_extend_trials_table
|
120
127
|
if extend_trials.any?
|
121
128
|
extend_trials.each do |extend_trial|
|
122
129
|
@apm_db.execute("INSERT INTO extend_trials (id ,shop_domain ,plan_id ,app_id ,days ,created_by ,created_at ,updated_at ,extend_trial_start_at ) VALUES (?,?,?,?,?,?,?,?,?)", extend_trial['id'], extend_trial['shop_domain'], extend_trial['plan_id'], extend_trial['app_id'], extend_trial['days'], extend_trial['created_by'], extend_trial['created_at'], extend_trial['updated_at'], extend_trial['extend_trial_start_at'])
|
@@ -126,7 +133,7 @@ module AppManager
|
|
126
133
|
|
127
134
|
def save_api_plan_users(plan_users)
|
128
135
|
@apm_db.execute("DROP TABLE IF EXISTS plan_users;")
|
129
|
-
|
136
|
+
create_plan_users_table
|
130
137
|
if plan_users.any?
|
131
138
|
plan_users.each do |plan_user|
|
132
139
|
@apm_db.execute("INSERT INTO plan_users (id ,shop_domain, plan_id, created_by, created_at, updated_at ) VALUES (?,?,?,?,?,?)", plan_user['id'], plan_user['shop_domain'], plan_user['plan_id'], plan_user['created_by'], plan_user['created_at'], plan_user['updated_at'])
|
@@ -150,6 +157,34 @@ module AppManager
|
|
150
157
|
return app_structures
|
151
158
|
end
|
152
159
|
|
160
|
+
def create_plan_table
|
161
|
+
@apm_db.execute "CREATE TABLE IF NOT EXISTS plans(id integer,type varchar(255), name varchar(255), price float, offer_text varchar(255), description varchar(255), interval text, shopify_plans text, trial_days integer, test boolean, on_install integer, is_custom boolean, app_id integer, base_plan integer, created_at datetime, updated_at datetime, public boolean, discount integer, cycle_count integer, store_base_plan boolean, choose_later_plan boolean, discount_type varchar(255), affiliate text, features text, deleted_at datetime)"
|
162
|
+
end
|
163
|
+
|
164
|
+
def create_charges_table
|
165
|
+
@apm_db.execute "CREATE TABLE IF NOT EXISTS charges(id INTEGER PRIMARY KEY,charge_id varchar(255),test boolean, status varchar(255),name varchar(255), type varchar(255), price float,interval varchar(255),trial_days integer,billing_on datetime,activated_on datetime,trial_ends_on datetime,cancelled_on datetime, expires_on datetime,plan_id integer,description text,shop_domain varchar(255),created_at datetime, updated_at datetime, app_id integer, sync boolean DEFAULT 0,process_type varchar(255))"
|
166
|
+
end
|
167
|
+
|
168
|
+
def create_apps_table
|
169
|
+
@apm_db.execute "CREATE TABLE IF NOT EXISTS apps(id integer,name varchar(255),slug varchar(255),url varchar(255),image varchar(255),api_token varchar(255),slack varchar(255), created_at datetime, updated_at datetime)"
|
170
|
+
end
|
171
|
+
|
172
|
+
def create_app_structures_table
|
173
|
+
@apm_db.execute "CREATE TABLE IF NOT EXISTS app_structures(banners text)"
|
174
|
+
end
|
175
|
+
|
176
|
+
def create_discount_plans_table
|
177
|
+
@apm_db.execute "CREATE TABLE IF NOT EXISTS discount_plans(id integer,discount integer,shop_domain varchar(255),cycle_count integer,plan_id integer, created_by integer,created_at datetime,updated_at datetime,app_id integer,discount_type varchar(255))"
|
178
|
+
end
|
179
|
+
|
180
|
+
def create_extend_trials_table
|
181
|
+
@apm_db.execute "CREATE TABLE IF NOT EXISTS extend_trials(id integer,shop_domain varchar(255),plan_id integer,app_id integer,days integer,created_by integer,created_at datetime,updated_at datetime,extend_trial_start_at datetime)"
|
182
|
+
end
|
183
|
+
|
184
|
+
def create_plan_users_table
|
185
|
+
@apm_db.execute "CREATE TABLE IF NOT EXISTS plan_users(id integer,shop_domain varchar(255),plan_id integer,created_by integer,created_at datetime,updated_at datetime)"
|
186
|
+
end
|
187
|
+
|
153
188
|
|
154
189
|
def get_local_plans(params)
|
155
190
|
plans_data = []
|
data/lib/app_manager/model.rb
CHANGED
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.1.
|
4
|
+
version: 1.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hulkapps
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|