Update backend/app/main.py
Browse files- backend/app/main.py +4 -45
backend/app/main.py
CHANGED
|
@@ -645,53 +645,12 @@ async def get_assets(
|
|
| 645 |
print(f"ORM query error: {orm_error}")
|
| 646 |
assets = []
|
| 647 |
|
| 648 |
-
#
|
| 649 |
-
|
| 650 |
-
{
|
| 651 |
-
"id": "9991", # Return as string for consistency
|
| 652 |
-
"name": "OCR_Demo_Screenshot.png",
|
| 653 |
-
"file_type": "image",
|
| 654 |
-
"product_category": "ocr",
|
| 655 |
-
"sub_category": None,
|
| 656 |
-
"size": 2516582,
|
| 657 |
-
"created_at": datetime(2024, 12, 20)
|
| 658 |
-
},
|
| 659 |
-
{
|
| 660 |
-
"id": "9992", # Return as string for consistency
|
| 661 |
-
"name": "P2P_Workflow_Diagram.pdf",
|
| 662 |
-
"file_type": "document",
|
| 663 |
-
"product_category": "p2p",
|
| 664 |
-
"sub_category": "Budget Approval Workflow",
|
| 665 |
-
"size": 1024000,
|
| 666 |
-
"created_at": datetime(2024, 12, 19)
|
| 667 |
-
},
|
| 668 |
-
{
|
| 669 |
-
"id": "9993", # Return as string for consistency
|
| 670 |
-
"name": "O2C_Process_Video.mp4",
|
| 671 |
-
"file_type": "video",
|
| 672 |
-
"product_category": "o2c",
|
| 673 |
-
"sub_category": "Sales Order Workflow",
|
| 674 |
-
"size": 15728640,
|
| 675 |
-
"created_at": datetime(2024, 12, 18)
|
| 676 |
-
}
|
| 677 |
-
]
|
| 678 |
-
|
| 679 |
-
# Combine real assets with mock assets (real assets first)
|
| 680 |
-
return assets + mock_assets
|
| 681 |
except Exception as e:
|
| 682 |
-
# If database query fails, return mock data
|
| 683 |
print(f"Database query warning: {e}")
|
| 684 |
-
return [
|
| 685 |
-
{
|
| 686 |
-
"id": 1,
|
| 687 |
-
"name": "OCR_Demo_Screenshot.png",
|
| 688 |
-
"file_type": "image",
|
| 689 |
-
"product_category": "ocr",
|
| 690 |
-
"sub_category": None,
|
| 691 |
-
"size": 2516582,
|
| 692 |
-
"created_at": datetime.utcnow()
|
| 693 |
-
}
|
| 694 |
-
]
|
| 695 |
|
| 696 |
@app.delete("/api/assets/{asset_id}")
|
| 697 |
async def delete_asset(asset_id, db: Session = Depends(get_db)):
|
|
|
|
| 645 |
print(f"ORM query error: {orm_error}")
|
| 646 |
assets = []
|
| 647 |
|
| 648 |
+
# Return only real assets from database (no mock data)
|
| 649 |
+
return assets
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 650 |
except Exception as e:
|
| 651 |
+
# If database query fails, return empty array (no mock data)
|
| 652 |
print(f"Database query warning: {e}")
|
| 653 |
+
return []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 654 |
|
| 655 |
@app.delete("/api/assets/{asset_id}")
|
| 656 |
async def delete_asset(asset_id, db: Session = Depends(get_db)):
|