DmitrMakeev
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -769,8 +769,6 @@ def send_request():
|
|
769 |
|
770 |
|
771 |
|
772 |
-
DATABASE_NAME = 'data_gc.db'
|
773 |
-
|
774 |
DATABASE_NAME = 'data_gc.db'
|
775 |
|
776 |
def update_or_insert_user(db_name, user_data, mapping_template):
|
@@ -786,7 +784,7 @@ def update_or_insert_user(db_name, user_data, mapping_template):
|
|
786 |
for json_key, db_column in mapping_template.items():
|
787 |
value = user_data.get(json_key, "")
|
788 |
if isinstance(value, list):
|
789 |
-
transformed_data[db_column] = "1" if value else "0"
|
790 |
else:
|
791 |
transformed_data[db_column] = str(value)
|
792 |
|
@@ -802,7 +800,11 @@ def update_or_insert_user(db_name, user_data, mapping_template):
|
|
802 |
transformed_data[field] = ""
|
803 |
|
804 |
if user:
|
805 |
-
|
|
|
|
|
|
|
|
|
806 |
|
807 |
update_query = "UPDATE contacts SET "
|
808 |
update_values = []
|
@@ -810,7 +812,7 @@ def update_or_insert_user(db_name, user_data, mapping_template):
|
|
810 |
update_query += f"{column} = ?, "
|
811 |
update_values.append(value)
|
812 |
update_query += "web_st = ? WHERE email = ?"
|
813 |
-
update_values.extend([
|
814 |
cursor.execute(update_query, update_values)
|
815 |
else:
|
816 |
columns = ', '.join(transformed_data.keys()) + ", web_st"
|
|
|
769 |
|
770 |
|
771 |
|
|
|
|
|
772 |
DATABASE_NAME = 'data_gc.db'
|
773 |
|
774 |
def update_or_insert_user(db_name, user_data, mapping_template):
|
|
|
784 |
for json_key, db_column in mapping_template.items():
|
785 |
value = user_data.get(json_key, "")
|
786 |
if isinstance(value, list):
|
787 |
+
transformed_data[db_column] = "-1" if value else "0"
|
788 |
else:
|
789 |
transformed_data[db_column] = str(value)
|
790 |
|
|
|
800 |
transformed_data[field] = ""
|
801 |
|
802 |
if user:
|
803 |
+
web_st_value = user[0]
|
804 |
+
if web_st_value is None or web_st_value == "":
|
805 |
+
web_st_value = 0
|
806 |
+
else:
|
807 |
+
web_st_value = int(web_st_value) + 1
|
808 |
|
809 |
update_query = "UPDATE contacts SET "
|
810 |
update_values = []
|
|
|
812 |
update_query += f"{column} = ?, "
|
813 |
update_values.append(value)
|
814 |
update_query += "web_st = ? WHERE email = ?"
|
815 |
+
update_values.extend([web_st_value, email])
|
816 |
cursor.execute(update_query, update_values)
|
817 |
else:
|
818 |
columns = ', '.join(transformed_data.keys()) + ", web_st"
|