Skip to content

Conversation

@gustaavik
Copy link
Member

This pull request introduces enhancements to checkout management, focusing on cleanup operations, reactivation of abandoned checkouts, and improved repository functionality. It also includes updates to the documentation and adds comprehensive tests for checkout behaviors. The most important changes are grouped into themes below.

Cleanup Operations

  • Added a new force-delete-checkouts command in the Makefile to perform aggressive cleanup of expired, abandoned, and old completed checkouts. This complements the existing expire-checkouts command. (Makefile, MakefileR132-R134)
  • Introduced the ForceDeleteAllExpiredCheckouts method in CheckoutUseCase, which forcefully deletes expired checkouts using the repository's new GetAllExpiredCheckoutsForDeletion method. (internal/application/usecase/checkout_usecase.go, [1] [2]

Reactivation of Abandoned Checkouts

  • Implemented logic in GetOrCreateCheckoutBySessionIDWithCurrency to reactivate abandoned checkouts when no active checkout is found. This includes updating the checkout's status and optionally changing its currency. (internal/application/usecase/checkout_usecase.go, internal/application/usecase/checkout_usecase.goR805-R824)
  • Added a Reactivate method to the Checkout entity, allowing abandoned checkouts to be marked as active again. (internal/domain/entity/checkout.go, internal/domain/entity/checkout.goR370-R375)

Repository Enhancements

  • Updated the CheckoutRepository interface to include methods for retrieving abandoned checkouts by session ID and expired checkouts for deletion. (internal/domain/repository/checkout_repository.go, [1] [2]
  • Modified the Update method in the GORM-based CheckoutRepository to handle item deletions more robustly, ensuring removed items are deleted from the database. (internal/infrastructure/repository/gorm/checkout_repository.go, internal/infrastructure/repository/gorm/checkout_repository.goL210-R271)

Documentation Updates

  • Expanded the readme.md with detailed instructions for using and scheduling the new cleanup commands. This includes examples for regular and force cleanup operations. (readme.md, readme.mdR484-R543)

Testing Improvements

@gustaavik gustaavik merged commit 8f60dfa into main Jul 6, 2025
5 checks passed
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