m8chaa commited on
Commit
c7238ad
·
verified ·
1 Parent(s): 3ce78c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -76,7 +76,7 @@ class SheetUpdateRequest(BaseModel):
76
  target_sheet_id: int
77
  data: list
78
 
79
- def convert_dicts_to_list(dicts: List[Dict], add_link: bool = False,
80
  image_id: str = '', link_text: str = '',
81
  link_position: int = -1) -> List[List[str]]:
82
  rows = []
@@ -84,7 +84,8 @@ def convert_dicts_to_list(dicts: List[Dict], add_link: bool = False,
84
 
85
  for dict_item in dicts:
86
  # row = list(dict_item.values())
87
- row = [str(value) for value in dict_item.values()]
 
88
 
89
  # Always add timestamp to the first index
90
  row.insert(0, timestamp)
@@ -543,7 +544,8 @@ async def update_user_sheets_and_folders(user_data, transaction_ref, transaction
543
  if found_receipt_no > 0:
544
  new_folder = user_data['gDrive_metadata']['receipts']
545
  receipts_data = convert_dicts_to_list(
546
- data['receipts'],
 
547
  add_link=True,
548
  image_id=image_id,
549
  link_text="바로가기",
@@ -558,7 +560,8 @@ async def update_user_sheets_and_folders(user_data, transaction_ref, transaction
558
  else:
559
  secondary_folder = user_data['gDrive_metadata']['business_cards']
560
  business_cards_data = convert_dicts_to_list(
561
- data['busi_cards'],
 
562
  add_link=True,
563
  image_id=image_id,
564
  link_text="명함보기",
 
76
  target_sheet_id: int
77
  data: list
78
 
79
+ def convert_dicts_to_list(dicts: List[Dict], headers: List[str], add_link: bool = False,
80
  image_id: str = '', link_text: str = '',
81
  link_position: int = -1) -> List[List[str]]:
82
  rows = []
 
84
 
85
  for dict_item in dicts:
86
  # row = list(dict_item.values())
87
+ # row = [str(value) for value in dict_item.values()]
88
+ row = [str(dict_item.get(header, '')) for header in headers]
89
 
90
  # Always add timestamp to the first index
91
  row.insert(0, timestamp)
 
544
  if found_receipt_no > 0:
545
  new_folder = user_data['gDrive_metadata']['receipts']
546
  receipts_data = convert_dicts_to_list(
547
+ data['receipts'],
548
+ sms_sheet_headers,
549
  add_link=True,
550
  image_id=image_id,
551
  link_text="바로가기",
 
560
  else:
561
  secondary_folder = user_data['gDrive_metadata']['business_cards']
562
  business_cards_data = convert_dicts_to_list(
563
+ data['busi_cards'],
564
+ business_card_sheet_headers,
565
  add_link=True,
566
  image_id=image_id,
567
  link_text="명함보기",