Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -116,18 +116,6 @@ def get_item_details():
|
|
116 |
result = sf.query(soql)
|
117 |
|
118 |
if result['totalSize'] == 0:
|
119 |
-
soql_fallback = f"SELECT Name, Image_URL__c FROM Ingredient_Object__c WHERE Name LIKE '%{item_name}%' LIMIT 1"
|
120 |
-
result_fallback = sf.query(soql_fallback)
|
121 |
-
if result_fallback['totalSize'] > 0:
|
122 |
-
record = result_fallback['records'][0]
|
123 |
-
item_details = {
|
124 |
-
"name": record.get('Name', ''),
|
125 |
-
"description": "Description not available",
|
126 |
-
"ingredients": "Ingredients not listed",
|
127 |
-
"image_url": record.get('Image_URL__c', '')
|
128 |
-
}
|
129 |
-
logger.info(f"Fallback: Found '{item_name}' in Ingredient_Object__c")
|
130 |
-
return jsonify({"item_details": item_details})
|
131 |
return jsonify({"error": f"No item found matching '{item_name}' in Ingredient_Object__c"}), 404
|
132 |
|
133 |
record = result['records'][0]
|
@@ -160,9 +148,9 @@ def submit_items():
|
|
160 |
for item in items:
|
161 |
sf.Ingredient_Object__c.create({
|
162 |
'Name': item['name'],
|
163 |
-
'Description__c': item
|
164 |
-
'Ingredients__c': item
|
165 |
-
'Image_URL__c': item
|
166 |
'Category__c': item.get('category', 'Both')
|
167 |
})
|
168 |
logger.info(f"Submitted item to Ingredient_Object__c: {item['name']}")
|
|
|
116 |
result = sf.query(soql)
|
117 |
|
118 |
if result['totalSize'] == 0:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
return jsonify({"error": f"No item found matching '{item_name}' in Ingredient_Object__c"}), 404
|
120 |
|
121 |
record = result['records'][0]
|
|
|
148 |
for item in items:
|
149 |
sf.Ingredient_Object__c.create({
|
150 |
'Name': item['name'],
|
151 |
+
'Description__c': item.get('description', 'No description available'),
|
152 |
+
'Ingredients__c': item.get('ingredients', 'No ingredients listed'),
|
153 |
+
'Image_URL__c': item.get('image_url', ''),
|
154 |
'Category__c': item.get('category', 'Both')
|
155 |
})
|
156 |
logger.info(f"Submitted item to Ingredient_Object__c: {item['name']}")
|