Spaces:
Running
Running
Create backend/app/models.py
Browse files- backend/app/models.py +32 -0
backend/app/models.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sqlalchemy import Column, Integer, String, Float, DateTime, Text
|
| 2 |
+
from sqlalchemy.sql import func
|
| 3 |
+
|
| 4 |
+
from .db import Base
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class ExtractionRecord(Base):
|
| 8 |
+
"""
|
| 9 |
+
Stores one extraction run so the History page can show past jobs.
|
| 10 |
+
We’ll fill it from the /api/extract endpoint later.
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
__tablename__ = "extractions"
|
| 14 |
+
|
| 15 |
+
id = Column(Integer, primary_key=True, index=True)
|
| 16 |
+
|
| 17 |
+
file_name = Column(String, index=True)
|
| 18 |
+
file_type = Column(String)
|
| 19 |
+
file_size = Column(String)
|
| 20 |
+
|
| 21 |
+
status = Column(String) # "completed" | "failed"
|
| 22 |
+
confidence = Column(Float) # overall confidence (0–100)
|
| 23 |
+
fields_extracted = Column(Integer) # number of fields extracted
|
| 24 |
+
total_time_ms = Column(Integer) # total processing time in ms
|
| 25 |
+
|
| 26 |
+
raw_output = Column(Text) # JSON string from the model
|
| 27 |
+
error_message = Column(Text, nullable=True)
|
| 28 |
+
|
| 29 |
+
created_at = Column(
|
| 30 |
+
DateTime(timezone=True),
|
| 31 |
+
server_default=func.now(),
|
| 32 |
+
)
|