-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheck_document_db.py
More file actions
57 lines (47 loc) · 1.74 KB
/
Copy pathcheck_document_db.py
File metadata and controls
57 lines (47 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
Debug script to check what's actually in the database after document upload
"""
from db.database import SessionLocal
from db.models import Document
import json
def check_latest_document():
"""Check the latest document in database"""
db = SessionLocal()
try:
# Get the most recent document
doc = db.query(Document).order_by(Document.created_at.desc()).first()
if not doc:
print("No documents found in database")
return
print("="*80)
print("LATEST DOCUMENT IN DATABASE")
print("="*80)
print(f"\nDocument ID: {doc.document_id}")
print(f"Filename: {doc.filename}")
print(f"Status: {doc.status}")
print(f"Transaction ID: {doc.transaction_id}")
print(f"Risk Score: {doc.risk_score}")
print(f"Risk Band: {doc.risk_band}")
print(f"\n" + "="*80)
print("WORKFLOW METADATA")
print("="*80)
if doc.workflow_metadata:
print(json.dumps(doc.workflow_metadata, indent=2, default=str))
else:
print("No workflow metadata stored")
print(f"\n" + "="*80)
print("FINDINGS")
print("="*80)
# Check if there are any findings
if doc.findings:
print(f"Found {len(doc.findings)} findings:")
for finding in doc.findings:
print(f"\n - Type: {finding.finding_type}")
print(f" Severity: {finding.finding_severity}")
print(f" Description: {finding.finding_description}")
else:
print("No findings stored in database")
finally:
db.close()
if __name__ == "__main__":
check_latest_document()