DmitrMakeev
commited on
Commit
•
4cec78a
1
Parent(s):
d872b34
Update app.py
Browse files
app.py
CHANGED
@@ -806,26 +806,30 @@ 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 b_fin FROM contacts WHERE email = ?", (email,))
|
810 |
user = cursor.fetchone()
|
811 |
logging.debug(f"User found: {user}")
|
812 |
|
813 |
-
# Вынесение увеличения
|
814 |
-
|
|
|
815 |
if user:
|
816 |
-
# Проверка
|
817 |
-
|
|
|
|
|
|
|
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 |
-
# Обновление
|
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,7 +874,8 @@ def update_or_insert_user(db_name, user_data, mapping_template):
|
|
870 |
transformed_data['phone'] = phone
|
871 |
logging.debug(f"Transformed data after phone processing: {transformed_data}")
|
872 |
|
873 |
-
# Добавление
|
|
|
874 |
transformed_data['b_fin'] = b_fin_value
|
875 |
|
876 |
# Обновление данных пользователя в базе данных
|
|
|
806 |
logging.debug(f"Processing user with email: {email}")
|
807 |
|
808 |
# Проверка существования пользователя в базе данных по email
|
809 |
+
cursor.execute("SELECT web_st, b_fin FROM contacts WHERE email = ?", (email,))
|
810 |
user = cursor.fetchone()
|
811 |
logging.debug(f"User found: {user}")
|
812 |
|
813 |
+
# Вынесение увеличения значений web_st и b_fin в отдельные блоки
|
814 |
+
web_st_value = 1 # Инициализация значения web_st
|
815 |
+
b_fin_value = 0 # Инициализация значения b_fin
|
816 |
if user:
|
817 |
+
# Проверка текущих значений web_st и b_fin и их инкрементация
|
818 |
+
current_web_st = user[0] if user[0] is not None and user[0] != "" else 0
|
819 |
+
current_b_fin = user[1] if user[1] is not None and user[1] != "" else 0
|
820 |
+
|
821 |
+
web_st_value = int(current_web_st) + 1
|
822 |
if user_data.get('finished') == "True":
|
823 |
b_fin_value = int(current_b_fin) + 1
|
824 |
else:
|
825 |
b_fin_value = current_b_fin
|
826 |
+
logging.debug(f"Calculated web_st_value: {web_st_value}, b_fin_value: {b_fin_value}")
|
827 |
|
828 |
+
# Обновление значений web_st и b_fin
|
829 |
+
cursor.execute("UPDATE contacts SET web_st = ?, b_fin = ? WHERE email = ?", (web_st_value, b_fin_value, email))
|
830 |
conn.commit()
|
831 |
conn.close()
|
832 |
+
logging.debug(f"User {email} web_st updated to {web_st_value}, b_fin updated to {b_fin_value}")
|
833 |
else:
|
834 |
conn.close()
|
835 |
logging.debug(f"User {email} not found, proceeding with insert")
|
|
|
874 |
transformed_data['phone'] = phone
|
875 |
logging.debug(f"Transformed data after phone processing: {transformed_data}")
|
876 |
|
877 |
+
# Добавление значений web_st и b_fin в данные для вставки
|
878 |
+
transformed_data['web_st'] = web_st_value
|
879 |
transformed_data['b_fin'] = b_fin_value
|
880 |
|
881 |
# Обновление данных пользователя в базе данных
|