Skip to content

Conversation

@DiamondThe
Copy link

No description provided.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Юзкейсы - это бизнес-логика приложения. Обычно логирование к бизнес-логике не относится, но у тебя тут как-будто аудитлог, то есть бизнесовое требование сохранять все действия в сервисе. В таком случае лучше это назвать либо HistoryRecord, либо Event, либо AuditLog, чтобы можно было различать с системным логированием.

Также факт логирования у тебя не происходит отдельно сам по себе, поэтому это лучше вынести в сервисный слой

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Спасибо, учту)

self.log_use_case = log_use_case

async def execute(self, post_id: int, content: Optional[str] = None) -> Comment:
existing_comment = await self.comment_repository.get_by_id(post_id=post_id)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут и везде - если есть две записи в бд, которые не должны существовать отдельно друг от друга (в данном случае обновление комментария и лог об этом) то это нужно оборачивать в транзакцию



db_name = await conn.fetchval("SELECT current_database()")
print(f"📡 Connected to database: {db_name}")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants