Upload main.py
Browse files
main.py
CHANGED
@@ -310,7 +310,11 @@ def process_sheet_data(values): # For Value Categories
|
|
310 |
|
311 |
# Add lastUpdated if it exists in the sheet
|
312 |
if last_updated and str(last_updated).strip():
|
313 |
-
|
|
|
|
|
|
|
|
|
314 |
|
315 |
processed_data.append(processed_item)
|
316 |
return processed_data
|
@@ -741,11 +745,9 @@ async def update_cache_periodically():
|
|
741 |
category_changes_for_api.append(change_info)
|
742 |
change_detected_for_webhook = True
|
743 |
change_info_webhook = change_info # Store last change for potential webhook
|
744 |
-
# Add lastUpdated field to new_item when changes detected
|
745 |
-
new_item['lastUpdated'] = timestamp_iso
|
746 |
else:
|
747 |
-
# This is a new item, add lastUpdated field
|
748 |
-
|
749 |
|
750 |
# Prepare webhook only if a change was found AND cache was ready
|
751 |
if change_detected_for_webhook and cache["is_ready"] and VALUE_WEBHOOK_URL:
|
|
|
310 |
|
311 |
# Add lastUpdated if it exists in the sheet
|
312 |
if last_updated and str(last_updated).strip():
|
313 |
+
# Only add if it's in the format yyyy-MM-dd HH:mm:ss
|
314 |
+
last_updated_str = str(last_updated).strip()
|
315 |
+
# Check if it matches the expected date format
|
316 |
+
if re.match(r'^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$', last_updated_str):
|
317 |
+
processed_item['lastUpdated'] = last_updated_str
|
318 |
|
319 |
processed_data.append(processed_item)
|
320 |
return processed_data
|
|
|
745 |
category_changes_for_api.append(change_info)
|
746 |
change_detected_for_webhook = True
|
747 |
change_info_webhook = change_info # Store last change for potential webhook
|
|
|
|
|
748 |
else:
|
749 |
+
# This is a new item, but don't add lastUpdated field here
|
750 |
+
pass
|
751 |
|
752 |
# Prepare webhook only if a change was found AND cache was ready
|
753 |
if change_detected_for_webhook and cache["is_ready"] and VALUE_WEBHOOK_URL:
|