VietCat commited on
Commit
6535336
·
1 Parent(s): 86f006f

fix duplicate message

Browse files
Files changed (1) hide show
  1. app/sheets.py +9 -3
app/sheets.py CHANGED
@@ -90,11 +90,8 @@ class SheetsClient:
90
  history = []
91
 
92
  for row in values:
93
- logger.info(f"[DEBUG] Conversation: {row}")
94
  # Bổ sung cột rỗng cho đủ 12 cột
95
  row = row + [""] * (12 - len(row))
96
- logger.info(f"[DEBUG] Conversation: {row}")
97
- logger.info(f"[DEBUG] Conversation: {row[4]}:{user_id} - {row[5]}:{page_id} - {row[11]}/{row[11].lower()}")
98
  if row[4] == user_id and row[5] == page_id and row[11].lower() == 'false':
99
  history.append({
100
  'conversation_id': row[0],
@@ -209,6 +206,8 @@ class SheetsClient:
209
  body=body
210
  ).execute()
211
 
 
 
212
  # Return the conversation data directly
213
  return {
214
  'conversation_id': conversation_id,
@@ -265,6 +264,13 @@ class SheetsClient:
265
  body=body
266
  ).execute()
267
 
 
 
 
 
 
 
 
268
  # Return the updated conversation data
269
  return {
270
  'conversation_id': conversation_id,
 
90
  history = []
91
 
92
  for row in values:
 
93
  # Bổ sung cột rỗng cho đủ 12 cột
94
  row = row + [""] * (12 - len(row))
 
 
95
  if row[4] == user_id and row[5] == page_id and row[11].lower() == 'false':
96
  history.append({
97
  'conversation_id': row[0],
 
206
  body=body
207
  ).execute()
208
 
209
+ logger.info(f"Thêm mới conversation: {conversation_id} | Giá trị: {dict(zip(['conversation_id','command','content','attachments','user_id','page_id','message','vehicle','action','purpose','timestamp','is_done'], new_row))}")
210
+
211
  # Return the conversation data directly
212
  return {
213
  'conversation_id': conversation_id,
 
264
  body=body
265
  ).execute()
266
 
267
+ changed_cols = []
268
+ col_names = ['conversation_id','command','content','attachments','user_id','page_id','message','vehicle','action','purpose','timestamp','is_done']
269
+ for idx, (old, new) in enumerate(zip(current_row, new_row)):
270
+ if old != new:
271
+ changed_cols.append(col_names[idx])
272
+ logger.info(f"Cập nhật conversation: {conversation_id} tại dòng {row_index+1} | Cột cập nhật: {changed_cols} | Giá trị mới: {dict(zip(col_names, new_row))}")
273
+
274
  # Return the updated conversation data
275
  return {
276
  'conversation_id': conversation_id,