DmitrMakeev
commited on
Commit
•
0e2036e
1
Parent(s):
454005f
Update app.py
Browse files
app.py
CHANGED
@@ -781,6 +781,12 @@ def send_request():
|
|
781 |
|
782 |
|
783 |
DATABASE_NAME = 'data_gc.db'
|
|
|
|
|
|
|
|
|
|
|
|
|
784 |
def update_or_insert_user(db_name, user_data, mapping_template):
|
785 |
conn = sqlite3.connect(db_name)
|
786 |
cursor = conn.cursor()
|
@@ -823,8 +829,14 @@ def update_or_insert_user(db_name, user_data, mapping_template):
|
|
823 |
transformed_data = {}
|
824 |
for json_key, db_column in mapping_template.items():
|
825 |
value = user_data.get(json_key, "")
|
|
|
826 |
if isinstance(value, list):
|
827 |
-
|
|
|
|
|
|
|
|
|
|
|
828 |
else:
|
829 |
transformed_data[db_column] = str(value)
|
830 |
logging.debug(f"Transformed data: {transformed_data}")
|
@@ -875,6 +887,9 @@ def update_or_insert_user(db_name, user_data, mapping_template):
|
|
875 |
conn.commit()
|
876 |
conn.close()
|
877 |
logging.debug(f"User with email {email} processed successfully")
|
|
|
|
|
|
|
878 |
@app.route('/send_get_request', methods=['GET'])
|
879 |
def send_get_request():
|
880 |
token = request.args.get('token')
|
|
|
781 |
|
782 |
|
783 |
DATABASE_NAME = 'data_gc.db'
|
784 |
+
|
785 |
+
|
786 |
+
|
787 |
+
|
788 |
+
|
789 |
+
|
790 |
def update_or_insert_user(db_name, user_data, mapping_template):
|
791 |
conn = sqlite3.connect(db_name)
|
792 |
cursor = conn.cursor()
|
|
|
829 |
transformed_data = {}
|
830 |
for json_key, db_column in mapping_template.items():
|
831 |
value = user_data.get(json_key, "")
|
832 |
+
|
833 |
if isinstance(value, list):
|
834 |
+
# Проверяем тип элементов списка
|
835 |
+
if all(isinstance(item, str) for item in value):
|
836 |
+
transformed_data[db_column] = "; ".join(value) # Сохраняем сообщения в строку
|
837 |
+
else:
|
838 |
+
logging.error(f"Expected list of strings for key {json_key}, but got: {value}")
|
839 |
+
transformed_data[db_column] = ""
|
840 |
else:
|
841 |
transformed_data[db_column] = str(value)
|
842 |
logging.debug(f"Transformed data: {transformed_data}")
|
|
|
887 |
conn.commit()
|
888 |
conn.close()
|
889 |
logging.debug(f"User with email {email} processed successfully")
|
890 |
+
|
891 |
+
|
892 |
+
|
893 |
@app.route('/send_get_request', methods=['GET'])
|
894 |
def send_get_request():
|
895 |
token = request.args.get('token')
|