AMead10 commited on
Commit
58097c4
·
1 Parent(s): d647146

add some comments

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -72,16 +72,19 @@ def save_data(orig_user_email, constituent_email, labels, user_response):
72
  # body should be the original email
73
 
74
  try:
 
75
  db_cursor.execute(
76
  "INSERT INTO messages (app_id, org_id, person_id, communication_method_id, status_id, subject, body, send_date, message_type, volley) VALUES (0, 0, 0, 1, 1, 'Email Classification and Response Tracking', %s, NOW(), 'Email Classification and Response Tracking', 0)",
77
  (orig_user_email,),
78
  )
79
 
 
80
  db_cursor.execute(
81
  "INSERT INTO messages (app_id, org_id, person_id, communication_method_id, status_id, subject, body, send_date, message_type, volley) VALUES (0, 0, 0, 1, 1, 'Email Classification and Response Tracking', %s, NOW(), 'Email Classification and Response Tracking', 1)",
82
  (constituent_email,),
83
  )
84
 
 
85
  db_cursor.execute(
86
  "INSERT INTO messages (app_id, org_id, person_id, communication_method_id, status_id, subject, body, send_date, message_type, volley) VALUES (0, 0, 0, 1, 1, 'Email Classification and Response Tracking', %s, NOW(), 'Email Classification and Response Tracking', 2)",
87
  (user_response,),
@@ -90,16 +93,19 @@ def save_data(orig_user_email, constituent_email, labels, user_response):
90
  # insert a row into the message_categorys_associations table for each valid label in labels with the message_id of the constituent_email
91
  labels = labels.split(", ")
92
  for label in labels:
 
93
  label_exists = db_cursor.execute(
94
  "SELECT * FROM radmap_frog12.message_categorys WHERE message_category_name = %s",
95
  (label,),
96
  )
97
  label_exists = db_cursor.fetchall()
98
  if label_exists:
 
99
  db_cursor.execute(
100
  "INSERT INTO message_category_associations (message_id, message_category_id) VALUES ((SELECT id FROM messages WHERE body = %s), %i)",
101
  (constituent_email, label_exists[0][0]),
102
  )
 
103
 
104
  db_connection.commit()
105
 
 
72
  # body should be the original email
73
 
74
  try:
75
+ print("saving first email")
76
  db_cursor.execute(
77
  "INSERT INTO messages (app_id, org_id, person_id, communication_method_id, status_id, subject, body, send_date, message_type, volley) VALUES (0, 0, 0, 1, 1, 'Email Classification and Response Tracking', %s, NOW(), 'Email Classification and Response Tracking', 0)",
78
  (orig_user_email,),
79
  )
80
 
81
+ print("saving constituent email")
82
  db_cursor.execute(
83
  "INSERT INTO messages (app_id, org_id, person_id, communication_method_id, status_id, subject, body, send_date, message_type, volley) VALUES (0, 0, 0, 1, 1, 'Email Classification and Response Tracking', %s, NOW(), 'Email Classification and Response Tracking', 1)",
84
  (constituent_email,),
85
  )
86
 
87
+ print("saving user response")
88
  db_cursor.execute(
89
  "INSERT INTO messages (app_id, org_id, person_id, communication_method_id, status_id, subject, body, send_date, message_type, volley) VALUES (0, 0, 0, 1, 1, 'Email Classification and Response Tracking', %s, NOW(), 'Email Classification and Response Tracking', 2)",
90
  (user_response,),
 
93
  # insert a row into the message_categorys_associations table for each valid label in labels with the message_id of the constituent_email
94
  labels = labels.split(", ")
95
  for label in labels:
96
+ print("saving label: " + label)
97
  label_exists = db_cursor.execute(
98
  "SELECT * FROM radmap_frog12.message_categorys WHERE message_category_name = %s",
99
  (label,),
100
  )
101
  label_exists = db_cursor.fetchall()
102
  if label_exists:
103
+ print("label exists")
104
  db_cursor.execute(
105
  "INSERT INTO message_category_associations (message_id, message_category_id) VALUES ((SELECT id FROM messages WHERE body = %s), %i)",
106
  (constituent_email, label_exists[0][0]),
107
  )
108
+ print("label saved")
109
 
110
  db_connection.commit()
111