Skip to content

Commit

Permalink
📝 reduced @schedule check time to 10 seconds and made it so if the bu…
Browse files Browse the repository at this point in the history
…yer and the seller is the same in auction it does not create a chatroom
  • Loading branch information
jafacode committed Feb 1, 2025
1 parent c7c232f commit 6482920
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class AuctionService(
return auctionRepository.findByIdOrNull(auctionId) ?: throw AuctionNotFoundException()
}

@Scheduled(fixedRate = 60000) // Run every minute
@Scheduled(fixedRate = 10000)
fun checkAndEndAuctions() {
val now = Instant.now()
val endedAuctions = auctionRepository.findByEndTimeBeforeAndStatus(now, 0)
Expand Down Expand Up @@ -237,10 +237,13 @@ class AuctionService(
isDummy = 1,
)
articleRepository.save(articleEntity)
chatRoomService.createChatRoom(
articleEntity.id ?: throw IllegalArgumentException("Article ID cannot be null"),
articleEntity.seller.id ?: throw IllegalArgumentException("Seller ID cannot be null"),
articleEntity.buyer?.id ?: throw IllegalArgumentException("Buyer ID cannot be null"),
)
if (auction.seller.id != auction.bidder?.id)
{
chatRoomService.createChatRoom(
articleEntity.id ?: throw IllegalArgumentException("Article ID cannot be null"),
articleEntity.seller.id ?: throw IllegalArgumentException("Seller ID cannot be null"),
articleEntity.buyer?.id ?: throw IllegalArgumentException("Buyer ID cannot be null"),
)
}
}
}

0 comments on commit 6482920

Please sign in to comment.