Untitled
4ae4d
plain_text
01/19/2026 1:58 PM
1.7 KB
9
Indexable
from uuid import UUID
from sqlalchemy import select, update, desc
from sqlalchemy.orm import selectinload
from ..db.models import User, UserTag, Participation, Event, AppTagEvent # <-- добавили Event, AppTagEvent
from .base import SQLRepository
class UserRepository(SQLRepository):
model = User
async def get_by_messenger_id(self, id: int):
query = (
select(self.model)
.options(
selectinload(self.model.city),
# user tags (у вас так и было)
selectinload(self.model.user_tags).selectinload(UserTag.app_tag),
selectinload(self.model.custom_tags),
# participations -> event -> app tags
selectinload(self.model.participations)
.selectinload(Participation.event)
.selectinload(Event.app_tag_events)
.selectinload(AppTagEvent.app_tag),
# creator events -> app tags
selectinload(self.model.events)
.selectinload(Event.app_tag_events)
.selectinload(AppTagEvent.app_tag),
)
.where(self.model.messenger_id == id)
)
result = await self.session.execute(query)
return result.scalars().first()
Editor is loading...
Leave a Comment