DmitrMakeev
commited on
Commit
•
997ee2b
1
Parent(s):
da799e4
Update app.py
Browse files
app.py
CHANGED
@@ -735,7 +735,7 @@ def send_to_google_forms(user_data, gog_url):
|
|
735 |
logging.error(f"Failed to send data to Google Forms for user: {user_data.get('email')}. Response: {response.text}")
|
736 |
|
737 |
|
738 |
-
def update_or_insert_user(db_name, user_data, mapping_template
|
739 |
conn = sqlite3.connect(db_name)
|
740 |
cursor = conn.cursor()
|
741 |
|
@@ -746,13 +746,12 @@ def update_or_insert_user(db_name, user_data, mapping_template, gog_url):
|
|
746 |
|
747 |
logging.debug(f"Processing user with email: {email}")
|
748 |
|
749 |
-
cursor.execute("SELECT web_st, ws_st
|
750 |
user = cursor.fetchone()
|
751 |
logging.debug(f"User found: {user}")
|
752 |
|
753 |
current_web_st = user[0] if user else None
|
754 |
current_ws_st = user[1] if user else None
|
755 |
-
current_messages = user[2] if user else ""
|
756 |
|
757 |
transformed_data = {}
|
758 |
for json_key, db_column in mapping_template.items():
|
@@ -797,13 +796,6 @@ def update_or_insert_user(db_name, user_data, mapping_template, gog_url):
|
|
797 |
else:
|
798 |
transformed_data['web_st'] = 1
|
799 |
|
800 |
-
new_messages = transformed_data.get('b_mess', "")
|
801 |
-
if current_messages:
|
802 |
-
transformed_data['b_mess'] = current_messages + "; " + new_messages
|
803 |
-
else:
|
804 |
-
transformed_data['b_mess'] = new_messages
|
805 |
-
logging.debug(f"Transformed data after message processing: {transformed_data}")
|
806 |
-
|
807 |
if user:
|
808 |
update_query = "UPDATE contacts SET "
|
809 |
update_values = []
|
@@ -826,9 +818,6 @@ def update_or_insert_user(db_name, user_data, mapping_template, gog_url):
|
|
826 |
conn.close()
|
827 |
logging.debug(f"User with email {email} processed successfully")
|
828 |
|
829 |
-
# Отправка данных в Google Forms
|
830 |
-
send_to_google_forms(transformed_data, gog_url)
|
831 |
-
|
832 |
|
833 |
@app.route('/send_request', methods=['POST'])
|
834 |
def send_request():
|
|
|
735 |
logging.error(f"Failed to send data to Google Forms for user: {user_data.get('email')}. Response: {response.text}")
|
736 |
|
737 |
|
738 |
+
def update_or_insert_user(db_name, user_data, mapping_template):
|
739 |
conn = sqlite3.connect(db_name)
|
740 |
cursor = conn.cursor()
|
741 |
|
|
|
746 |
|
747 |
logging.debug(f"Processing user with email: {email}")
|
748 |
|
749 |
+
cursor.execute("SELECT web_st, ws_st FROM contacts WHERE email = ?", (email,))
|
750 |
user = cursor.fetchone()
|
751 |
logging.debug(f"User found: {user}")
|
752 |
|
753 |
current_web_st = user[0] if user else None
|
754 |
current_ws_st = user[1] if user else None
|
|
|
755 |
|
756 |
transformed_data = {}
|
757 |
for json_key, db_column in mapping_template.items():
|
|
|
796 |
else:
|
797 |
transformed_data['web_st'] = 1
|
798 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
799 |
if user:
|
800 |
update_query = "UPDATE contacts SET "
|
801 |
update_values = []
|
|
|
818 |
conn.close()
|
819 |
logging.debug(f"User with email {email} processed successfully")
|
820 |
|
|
|
|
|
|
|
821 |
|
822 |
@app.route('/send_request', methods=['POST'])
|
823 |
def send_request():
|