DmitrMakeev commited on
Commit
c6b468b
1 Parent(s): 4987565

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -212,6 +212,16 @@ def export_user():
212
 
213
 
214
 
 
 
 
 
 
 
 
 
 
 
215
  def load_data_from_json(json_data):
216
  data = json_data
217
  items = data['info']['items']
@@ -238,9 +248,6 @@ def load_data_from_json(json_data):
238
  user_data.setdefault('pr4', '')
239
  user_data.setdefault('pr5', '')
240
  user_data.setdefault('ad_url', '')
241
- user_data.setdefault('key_pr', '')
242
- user_data.setdefault('canal', '')
243
- user_data.setdefault('data_t', '')
244
 
245
  # Убираем плюс в начале телефона, если он присутствует
246
  if 'Телефон' in user_data and user_data['Телефон'].startswith('+'):
@@ -248,9 +255,9 @@ def load_data_from_json(json_data):
248
 
249
  query = '''
250
  INSERT INTO contacts (
251
- name, phone, email, vk_id, chat_id, ws_statys, ws_stop, web_statys, fin_progress, shop_statys_full, pr1, pr2, pr3, pr4, pr5, ad_url, curator, key_pr, canal, data_t
252
  ) VALUES (
253
- :Имя, :Телефон, :Email, :vk_id, :chat_id, :ws_st, :ws_stop, :web_st, :fin_prog, :shop_st, :pr1, :pr2, :pr3, :pr4, :pr5, :ad_url, :curator, :key_pr, :canal, :data_t
254
  )
255
  '''
256
  cursor.execute(query, user_data)
@@ -289,10 +296,6 @@ def start():
289
 
290
 
291
 
292
-
293
-
294
-
295
-
296
 
297
  def randomize_message(template):
298
  def replace_placeholder(match):
 
212
 
213
 
214
 
215
+ def send_second_request(export_id):
216
+ api_key = api_key_sys
217
+ api_url_template = 'https://school.riverpsy.com/pl/api/account/exports/{export_id}?key={api_key}'
218
+ api_url = api_url_template.format(export_id=export_id, api_key=api_key)
219
+ response = requests.get(api_url)
220
+ if response.status_code == 200:
221
+ return response.json()
222
+ else:
223
+ raise Exception(f"Failed to fetch data, status code: {response.status_code}")
224
+
225
  def load_data_from_json(json_data):
226
  data = json_data
227
  items = data['info']['items']
 
248
  user_data.setdefault('pr4', '')
249
  user_data.setdefault('pr5', '')
250
  user_data.setdefault('ad_url', '')
 
 
 
251
 
252
  # Убираем плюс в начале телефона, если он присутствует
253
  if 'Телефон' in user_data and user_data['Телефон'].startswith('+'):
 
255
 
256
  query = '''
257
  INSERT INTO contacts (
258
+ name, phone, email, vk_id, chat_id, ws_statys, ws_stop, web_statys, fin_progress, shop_statys_full, pr1, pr2, pr3, pr4, pr5, ad_url, curator
259
  ) VALUES (
260
+ :Имя, :Телефон, :Email, :vk_id, :chat_id, :ws_st, :ws_stop, :web_st, :fin_prog, :shop_st, :pr1, :pr2, :pr3, :pr4, :pr5, :ad_url, :curator
261
  )
262
  '''
263
  cursor.execute(query, user_data)
 
296
 
297
 
298
 
 
 
 
 
299
 
300
  def randomize_message(template):
301
  def replace_placeholder(match):