Files
2026-10-23 15:12:43 +03:00

18 lines
655 B
Python

"""Synthetic message history shared by EXPLAIN and cache measurements."""
from datetime import datetime, timedelta, timezone
from sqlalchemy import insert, update
from src.models import Chat, Message
def seed_messages(session, chat_id, user_id, count=10000):
start = datetime(2026, 1, 1, tzinfo=timezone.utc)
session.execute(insert(Message), [
{'chat_id': chat_id, 'sender_id': user_id, 'text': 'synthetic ' * 100,
'created_at': start + timedelta(milliseconds=n)}
for n in range(1, count + 1)
])
session.execute(update(Chat).where(Chat.id == chat_id).values(
history_version=Chat.history_version + 1))