Seth commited on
Commit
36b5a20
·
1 Parent(s): d88cd5a
backend/app/main.py CHANGED
@@ -547,7 +547,7 @@ async def upload_asset(
547
  # This allows the app to work even if DB has issues
548
  print(f"Database save warning: {db_error}")
549
  return {
550
- "id": 1,
551
  "name": file.filename,
552
  "file_type": file_type,
553
  "product_category": product_category,
@@ -648,7 +648,7 @@ async def get_assets(
648
  # Merge with mock data (as requested - keep dummy content)
649
  mock_assets = [
650
  {
651
- "id": 9991,
652
  "name": "OCR_Demo_Screenshot.png",
653
  "file_type": "image",
654
  "product_category": "ocr",
@@ -657,7 +657,7 @@ async def get_assets(
657
  "created_at": datetime(2024, 12, 20)
658
  },
659
  {
660
- "id": 9992,
661
  "name": "P2P_Workflow_Diagram.pdf",
662
  "file_type": "document",
663
  "product_category": "p2p",
@@ -666,7 +666,7 @@ async def get_assets(
666
  "created_at": datetime(2024, 12, 19)
667
  },
668
  {
669
- "id": 9993,
670
  "name": "O2C_Process_Video.mp4",
671
  "file_type": "video",
672
  "product_category": "o2c",
 
547
  # This allows the app to work even if DB has issues
548
  print(f"Database save warning: {db_error}")
549
  return {
550
+ "id": "1", # Return as string for consistency
551
  "name": file.filename,
552
  "file_type": file_type,
553
  "product_category": product_category,
 
648
  # Merge with mock data (as requested - keep dummy content)
649
  mock_assets = [
650
  {
651
+ "id": "9991", # Return as string for consistency
652
  "name": "OCR_Demo_Screenshot.png",
653
  "file_type": "image",
654
  "product_category": "ocr",
 
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",
 
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",
frontend/src/pages/Repository.jsx CHANGED
@@ -84,14 +84,14 @@ const products = [
84
  ];
85
 
86
  const mockAssets = [
87
- { id: 1, name: 'OCR_Demo_Screenshot.png', type: 'image', product: 'ocr', subCategory: null, size: '2.4 MB', date: '2024-12-20' },
88
- { id: 2, name: 'P2P_Workflow_Diagram.pdf', type: 'document', product: 'p2p', subCategory: 'Budget Approval Workflow', size: '1.8 MB', date: '2024-12-19' },
89
- { id: 3, name: 'Invoice_Processing_Video.mp4', type: 'video', product: 'ocr', subCategory: null, size: '45.2 MB', date: '2024-12-18' },
90
- { id: 4, name: 'Sales_Order_Infographic.png', type: 'image', product: 'o2c', subCategory: 'Sales Order Workflow', size: '3.1 MB', date: '2024-12-17' },
91
- { id: 5, name: 'AP_Automation_Brochure.pdf', type: 'document', product: 'p2p', subCategory: 'Accounts Payable Workflow', size: '5.6 MB', date: '2024-12-16' },
92
- { id: 6, name: 'O2C_Product_Banner.png', type: 'image', product: 'o2c', subCategory: 'Quotation Workflow', size: '1.2 MB', date: '2024-12-15' },
93
- { id: 7, name: 'Document_Parsing_Demo.png', type: 'image', product: 'ocr', subCategory: null, size: '890 KB', date: '2024-12-14' },
94
- { id: 8, name: 'PR_Workflow_Guide.pdf', type: 'document', product: 'p2p', subCategory: 'Purchase Request Workflow', size: '2.3 MB', date: '2024-12-13' },
95
  ];
96
 
97
  export default function Repository() {
@@ -156,8 +156,9 @@ export default function Repository() {
156
  if (response.ok) {
157
  const data = await response.json();
158
  // Convert API response to match mockAssets format
 
159
  const formattedAssets = data.map(asset => ({
160
- id: asset.id,
161
  name: asset.name,
162
  type: asset.file_type,
163
  product: asset.product_category,
@@ -398,6 +399,9 @@ export default function Repository() {
398
  const result = await response.json();
399
  results.push(result);
400
 
 
 
 
401
  // Update progress - file uploaded, now analyzing
402
  setUploadProgress(prev => ({
403
  ...prev,
@@ -411,7 +415,7 @@ export default function Repository() {
411
 
412
  // Start polling for analysis status if it's a document/image
413
  if (result.file_type === 'document' || result.file_type === 'image') {
414
- pollAssetStatus(result.id, file.name);
415
  } else {
416
  setUploadProgress(prev => ({
417
  ...prev,
 
84
  ];
85
 
86
  const mockAssets = [
87
+ { id: '1', name: 'OCR_Demo_Screenshot.png', type: 'image', product: 'ocr', subCategory: null, size: '2.4 MB', date: '2024-12-20' },
88
+ { id: '2', name: 'P2P_Workflow_Diagram.pdf', type: 'document', product: 'p2p', subCategory: 'Budget Approval Workflow', size: '1.8 MB', date: '2024-12-19' },
89
+ { id: '3', name: 'Invoice_Processing_Video.mp4', type: 'video', product: 'ocr', subCategory: null, size: '45.2 MB', date: '2024-12-18' },
90
+ { id: '4', name: 'Sales_Order_Infographic.png', type: 'image', product: 'o2c', subCategory: 'Sales Order Workflow', size: '3.1 MB', date: '2024-12-17' },
91
+ { id: '5', name: 'AP_Automation_Brochure.pdf', type: 'document', product: 'p2p', subCategory: 'Accounts Payable Workflow', size: '5.6 MB', date: '2024-12-16' },
92
+ { id: '6', name: 'O2C_Product_Banner.png', type: 'image', product: 'o2c', subCategory: 'Quotation Workflow', size: '1.2 MB', date: '2024-12-15' },
93
+ { id: '7', name: 'Document_Parsing_Demo.png', type: 'image', product: 'ocr', subCategory: null, size: '890 KB', date: '2024-12-14' },
94
+ { id: '8', name: 'PR_Workflow_Guide.pdf', type: 'document', product: 'p2p', subCategory: 'Purchase Request Workflow', size: '2.3 MB', date: '2024-12-13' },
95
  ];
96
 
97
  export default function Repository() {
 
156
  if (response.ok) {
157
  const data = await response.json();
158
  // Convert API response to match mockAssets format
159
+ // IMPORTANT: Keep IDs as strings to preserve precision for large CockroachDB IDs
160
  const formattedAssets = data.map(asset => ({
161
+ id: String(asset.id), // Explicitly convert to string to preserve precision
162
  name: asset.name,
163
  type: asset.file_type,
164
  product: asset.product_category,
 
399
  const result = await response.json();
400
  results.push(result);
401
 
402
+ // Ensure ID is kept as string to preserve precision
403
+ const assetId = String(result.id);
404
+
405
  // Update progress - file uploaded, now analyzing
406
  setUploadProgress(prev => ({
407
  ...prev,
 
415
 
416
  // Start polling for analysis status if it's a document/image
417
  if (result.file_type === 'document' || result.file_type === 'image') {
418
+ pollAssetStatus(assetId, file.name);
419
  } else {
420
  setUploadProgress(prev => ({
421
  ...prev,