DmitrMakeev commited on
Commit
47fbef3
·
verified ·
1 Parent(s): a5c24e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -15
app.py CHANGED
@@ -806,23 +806,26 @@ def update_or_insert_user(db_name, user_data, mapping_template):
806
  logging.debug(f"Processing user with email: {email}")
807
 
808
  # Проверка существования пользователя в базе данных по email
809
- cursor.execute("SELECT web_st FROM contacts WHERE email = ?", (email,))
810
  user = cursor.fetchone()
811
  logging.debug(f"User found: {user}")
812
 
813
- # Вынесение увеличения значения web_st в отдельный блок
814
- web_st_value = 1 # Инициализация значения web_st
815
  if user:
816
- # Проверка текущего значения web_st и его инкрементация
817
- current_web_st = user[0] if user[0] is not None and user[0] != "" else 0
818
- web_st_value = int(current_web_st) + 1
819
- logging.debug(f"Calculated web_st_value: {web_st_value}")
 
 
 
820
 
821
- # Обновление значения web_st
822
- cursor.execute("UPDATE contacts SET web_st = ? WHERE email = ?", (web_st_value, email))
823
  conn.commit()
824
  conn.close()
825
- logging.debug(f"User {email} web_st updated to {web_st_value}")
826
  else:
827
  conn.close()
828
  logging.debug(f"User {email} not found, proceeding with insert")
@@ -867,8 +870,8 @@ def update_or_insert_user(db_name, user_data, mapping_template):
867
  transformed_data['phone'] = phone
868
  logging.debug(f"Transformed data after phone processing: {transformed_data}")
869
 
870
- # Добавление значения web_st в данные для вставки
871
- transformed_data['web_st'] = web_st_value
872
 
873
  # Обновление данных пользователя в базе данных
874
  if user:
@@ -895,7 +898,6 @@ def update_or_insert_user(db_name, user_data, mapping_template):
895
  logging.debug(f"User with email {email} processed successfully")
896
 
897
 
898
-
899
  @app.route('/send_get_request', methods=['GET'])
900
  def send_get_request():
901
  token = request.args.get('token')
@@ -940,7 +942,6 @@ def send_get_request():
940
  return jsonify({'error': 'Failed to fetch data from the API'}), response.status_code
941
 
942
 
943
-
944
  @app.route('/webhookbz', methods=['POST'])
945
  def webhookbz():
946
  api_sys_control = request.args.get('api_sys')
@@ -1007,7 +1008,6 @@ def webhookbz():
1007
 
1008
 
1009
 
1010
-
1011
 
1012
  @app.route('/biz_v', methods=['GET'])
1013
  def biz_v():
 
806
  logging.debug(f"Processing user with email: {email}")
807
 
808
  # Проверка существования пользователя в базе данных по email
809
+ cursor.execute("SELECT b_fin FROM contacts WHERE email = ?", (email,))
810
  user = cursor.fetchone()
811
  logging.debug(f"User found: {user}")
812
 
813
+ # Вынесение увеличения значения b_fin в отдельный блок
814
+ b_fin_value = 1 # Инициализация значения b_fin
815
  if user:
816
+ # Проверка текущего значения b_fin и его инкрементация
817
+ current_b_fin = user[0] if user[0] is not None and user[0] != "" else 0
818
+ if user_data.get('finished') == "True":
819
+ b_fin_value = int(current_b_fin) + 1
820
+ else:
821
+ b_fin_value = current_b_fin
822
+ logging.debug(f"Calculated b_fin_value: {b_fin_value}")
823
 
824
+ # Обновление значения b_fin
825
+ cursor.execute("UPDATE contacts SET b_fin = ? WHERE email = ?", (b_fin_value, email))
826
  conn.commit()
827
  conn.close()
828
+ logging.debug(f"User {email} b_fin updated to {b_fin_value}")
829
  else:
830
  conn.close()
831
  logging.debug(f"User {email} not found, proceeding with insert")
 
870
  transformed_data['phone'] = phone
871
  logging.debug(f"Transformed data after phone processing: {transformed_data}")
872
 
873
+ # Добавление значения b_fin в данные для вставки
874
+ transformed_data['b_fin'] = b_fin_value
875
 
876
  # Обновление данных пользователя в базе данных
877
  if user:
 
898
  logging.debug(f"User with email {email} processed successfully")
899
 
900
 
 
901
  @app.route('/send_get_request', methods=['GET'])
902
  def send_get_request():
903
  token = request.args.get('token')
 
942
  return jsonify({'error': 'Failed to fetch data from the API'}), response.status_code
943
 
944
 
 
945
  @app.route('/webhookbz', methods=['POST'])
946
  def webhookbz():
947
  api_sys_control = request.args.get('api_sys')
 
1008
 
1009
 
1010
 
 
1011
 
1012
  @app.route('/biz_v', methods=['GET'])
1013
  def biz_v():