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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7010c3191509441af8f2164b82d8f51d10ac81e75a5d58dff8f171fe2f664eef
4
- data.tar.gz: 3ea1e09198fc5baae7704d5165f1aa8a2b96ef032256d6053892d38a23aa7818
3
+ metadata.gz: 49314ece09cae0fc0ff0215616397c7d3a46fd9ff962b7b2c67c2a4894170ab9
4
+ data.tar.gz: eab49d56c31b7b21a8c545b2179d2f1dc1369ca90dbb422b36f911073740d233
5
5
  SHA512:
6
- metadata.gz: 9d3e42810a41f71f1ef7a64eefef549d8a0b6dd2f0c8bf31dbb08ac059bf3ea835b27d10e895f550cf69030c3777cebf78a35118aed8b7d06d03d446addc1196
7
- data.tar.gz: 0b5d935014c38b62e4a0d14037195d5e33c98d4ab8108da60223f8dfc73148d517fdb54c2cc8ee836832d31bb1aaa6b2cba888a72750f038b6d6c2fdf2ffcfe2
6
+ metadata.gz: b3984d372c6fb85033b6a2945718424866ac36e92fa5c7de542b703bf4e5bcadc969b1a456e4f68f17cde123c310f18de57e512a8817f568a7f6e30f44efc522
7
+ data.tar.gz: 4b8210b8595f1efc87bb78910556a78f43f065c35019fc07c330b52c7e2dedd63ba901812bd758156191078d8b5be7e76a83fe07fecfcbe5eb82d789a16e22bc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- app_manager (1.1.4)
4
+ app_manager (1.1.5)
5
5
  httparty
6
6
  kaminari (>= 0.16.3)
7
7
  rails (>= 5.2.0)
@@ -70,12 +70,27 @@ module AppManager
70
70
 
71
71
  def users
72
72
  if model
73
- if params[:search]
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
- data = model.where("#{@shopify_domain} LIKE :search OR #{@shopify_email} LIKE :search", search: "%#{search}%").page(params[:page]).per(10)
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.page(params[:page]).per(10)
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
- @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)"
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
- @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))"
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
- @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)"
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
- @apm_db.execute "CREATE TABLE IF NOT EXISTS app_structures(banners text)"
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
- @apm_db.execute("DROP TABLE IF EXISTS discount_plans;")
109
- @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))"
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
- @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)"
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
- @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)"
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 = []
@@ -134,7 +134,7 @@ module AppManager
134
134
  end
135
135
  return plan_data
136
136
  else
137
- return 'feature_slugs is required'
137
+ return []
138
138
  end
139
139
  end
140
140
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AppManager
4
- VERSION = "1.1.4"
4
+ VERSION = "1.1.5"
5
5
  end
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
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-28 00:00:00.000000000 Z
11
+ date: 2022-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty