Skip to content

Conversation

@petrCher
Copy link
Member

@petrCher petrCher commented Oct 25, 2025

Изменения

При удалении item идет проверка на наличие сессий не являющихся активными, зарезервированными, просроченными, если такие есть то они происходит софт делит для сессий и их страйков, также удаляются events^ связанные с сессиями.

Детали реализации

В модели бд ничего не менял, так как любые доп функции для поля там работают только при хард делитах, которые мы не поддерживаем.

Check-List

  • Вы проверили свой код перед отправкой запроса?
  • Вы написали тесты к реализованным функциям?
    Тесты падают уже давно, надо будет стажерам дать их исправить)))
  • Вы не забыли применить форматирование black и isort для Back-End или Prettier для Front-End?

@profcomff profcomff deleted a comment from github-actions bot Oct 25, 2025
@petrCher petrCher changed the title added filter Добавил эндпоинт для удаления rental session Oct 25, 2025
@github-actions
Copy link

💩 Code linting failed, use black and isort to fix it.

@petrCher
Copy link
Member Author

Проверку на правильность удаления сессий и страйков протестил

RentalSession.query(session=db.session)
.filter(RentalSession.status == RentStatus.ACTIVE)
.filter(RentalSession.deadline_ts < datetime.datetime.now(tz=datetime.timezone.utc))
.filter(RentalSession.is_deleted == False)
Copy link
Member

Choose a reason for hiding this comment

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

не нужно

exist_session_item: list[RentalSession] = (
RentalSession.query(session=db.session)
.filter(RentalSession.user_id == user.get("id"), RentalSession.item_type_id == item_type_id)
.filter(RentalSession.is_deleted == False)
Copy link
Member

Choose a reason for hiding this comment

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

не нужно

session = RentalSession.get(id=session_id, session=db.session)
if not session:
raise ObjectNotFound(RentalSession, session_id)
if session.status == RentStatus.ACTIVE or session.status == RentStatus.RESERVED:
Copy link
Member

Choose a reason for hiding this comment

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

overdue

Comment on lines 495 to 496
if not session:
raise ObjectNotFound(RentalSession, session_id)
Copy link
Member

Choose a reason for hiding this comment

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

не нужно

raise ForbiddenAction(RentalSession)
RentalSession.delete(id=session_id, session=db.session)
return StatusResponseModel(
status="Success", message="Rental session has been deleted", ru="Сессия удалена из RentalAPI"
Copy link
Member

Choose a reason for hiding this comment

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

  • id сессии

@Zimovchik Zimovchik merged commit d4f9590 into main Nov 5, 2025
1 of 2 checks passed
@petrCher petrCher deleted the delete-session branch November 5, 2025 17:13
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.

Проставлять is_deleted=True для рентал сессии при софт делитах

3 participants