42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
from app.core.database import SessionLocal
|
|
from app.models.email_message import EmailMessage
|
|
from app.models.ticket import Ticket
|
|
|
|
db = SessionLocal()
|
|
|
|
# Check the mapping between original IDs and new IDs
|
|
tickets = db.query(Ticket).order_by(Ticket.id).limit(20).all()
|
|
print('Tickets (new ID -> subject):')
|
|
for t in tickets:
|
|
print(f' {t.id}: {t.subject[:60] if t.subject else "no subject"}')
|
|
|
|
# Check email ticket IDs
|
|
emails = db.query(EmailMessage).order_by(EmailMessage.ticket_id).limit(20).all()
|
|
print('\nEmails (ticket_id -> from):')
|
|
for e in emails:
|
|
print(f' {e.ticket_id}: {e.from_address[:30]}')
|
|
|
|
# The issue: emails have ticket_id=662+ but tickets have id=4+
|
|
# This means the ticket_map is not working correctly
|
|
|
|
# Let's check what the original IDs should be
|
|
print('\nChecking original ticket IDs from extracted data...')
|
|
import json
|
|
with open('migrations/scripts/transformed_full.json', 'r', encoding='utf-8') as f:
|
|
data = json.load(f)
|
|
|
|
# Show first 10 tickets with original IDs
|
|
print('\nFirst 10 tickets from transformed data:')
|
|
for t in data['tickets'][:10]:
|
|
orig_id = t['original_id']
|
|
subject = t['subject'][:50]
|
|
print(f' Original ID {orig_id}: {subject}')
|
|
|
|
# Show first 10 conversations with ticket_original_id
|
|
print('\nFirst 10 conversations from transformed data:')
|
|
for c in data['conversations'][:10]:
|
|
ticket_orig = c['ticket_original_id']
|
|
print(f' ticket_original_id={ticket_orig}, type={c["type"]}')
|
|
|
|
db.close()
|