DmitrMakeev
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -788,6 +788,10 @@ def update_or_insert_user(db_name, user_data, mapping_template):
|
|
788 |
|
789 |
# Получение email пользователя из данных
|
790 |
email = user_data.get('email')
|
|
|
|
|
|
|
|
|
791 |
logging.debug(f"Processing user with email: {email}")
|
792 |
|
793 |
# Проверка существования пользователя в базе данных по email
|
@@ -826,26 +830,25 @@ def update_or_insert_user(db_name, user_data, mapping_template):
|
|
826 |
logging.debug(f"Transformed data after phone processing: {transformed_data}")
|
827 |
|
828 |
# Вынесение увеличения значения web_st в отдельный блок
|
829 |
-
web_st_value =
|
830 |
if user:
|
831 |
# Проверка текущего значения web_st и его инкрементация
|
832 |
-
|
833 |
-
web_st_value
|
834 |
logging.debug(f"Calculated web_st_value: {web_st_value}")
|
835 |
|
836 |
# Обновление данных пользователя в базе данных
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
if cursor.rowcount == 0:
|
849 |
columns = ', '.join(transformed_data.keys()) + ", web_st"
|
850 |
placeholders = ', '.join('?' for _ in transformed_data) + ", ?"
|
851 |
insert_query = f"INSERT INTO contacts ({columns}) VALUES ({placeholders})"
|
@@ -858,9 +861,6 @@ def update_or_insert_user(db_name, user_data, mapping_template):
|
|
858 |
conn.close()
|
859 |
logging.debug(f"User with email {email} processed successfully")
|
860 |
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
@app.route('/send_get_request', methods=['GET'])
|
865 |
def send_get_request():
|
866 |
token = request.args.get('token')
|
@@ -920,6 +920,7 @@ def send_get_request():
|
|
920 |
|
921 |
|
922 |
|
|
|
923 |
|
924 |
|
925 |
@app.route('/biz_v', methods=['GET'])
|
|
|
788 |
|
789 |
# Получение email пользователя из данных
|
790 |
email = user_data.get('email')
|
791 |
+
if not email:
|
792 |
+
logging.error(f"User data missing email: {user_data}")
|
793 |
+
return
|
794 |
+
|
795 |
logging.debug(f"Processing user with email: {email}")
|
796 |
|
797 |
# Проверка существования пользователя в базе данных по email
|
|
|
830 |
logging.debug(f"Transformed data after phone processing: {transformed_data}")
|
831 |
|
832 |
# Вынесение увеличения значения web_st в отдельный блок
|
833 |
+
web_st_value = 1
|
834 |
if user:
|
835 |
# Проверка текущего значения web_st и его инкрементация
|
836 |
+
current_web_st = user[0] if user[0] is not None and user[0] != "" else 0
|
837 |
+
web_st_value = int(current_web_st) + 1
|
838 |
logging.debug(f"Calculated web_st_value: {web_st_value}")
|
839 |
|
840 |
# Обновление данных пользователя в базе данных
|
841 |
+
if user:
|
842 |
+
update_query = "UPDATE contacts SET "
|
843 |
+
update_values = []
|
844 |
+
for column, value in transformed_data.items():
|
845 |
+
update_query += f"{column} = ?, "
|
846 |
+
update_values.append(value)
|
847 |
+
update_query += "web_st = ? WHERE email = ?"
|
848 |
+
update_values.extend([web_st_value, email])
|
849 |
+
logging.debug(f"Update query: {update_query} with values: {update_values}")
|
850 |
+
cursor.execute(update_query, update_values)
|
851 |
+
else:
|
|
|
852 |
columns = ', '.join(transformed_data.keys()) + ", web_st"
|
853 |
placeholders = ', '.join('?' for _ in transformed_data) + ", ?"
|
854 |
insert_query = f"INSERT INTO contacts ({columns}) VALUES ({placeholders})"
|
|
|
861 |
conn.close()
|
862 |
logging.debug(f"User with email {email} processed successfully")
|
863 |
|
|
|
|
|
|
|
864 |
@app.route('/send_get_request', methods=['GET'])
|
865 |
def send_get_request():
|
866 |
token = request.args.get('token')
|
|
|
920 |
|
921 |
|
922 |
|
923 |
+
|
924 |
|
925 |
|
926 |
@app.route('/biz_v', methods=['GET'])
|