Skip to content

Commit

Permalink
обновляем счетчик уведомлений при очистке старых
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcom committed Nov 15, 2023
1 parent e35f28d commit 5849f7a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/scala/ru/org/linux/user/UserEventDao.scala
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,15 @@ class UserEventDao(ds: DataSource, val transactionManager: PlatformTransactionMa
* @param userId идентификационный номер пользователя
* @param maxEventsPerUser максимальное количество уведомлений для одного пользователя
*/
def cleanupOldEvents(userId: Int, maxEventsPerUser: Int): Unit =
def cleanupOldEvents(userId: Int, maxEventsPerUser: Int): Unit = transactional() { _ =>
jdbcTemplate.update(
"DELETE FROM user_events WHERE user_events.id IN " +
"(SELECT id FROM user_events WHERE userid=? ORDER BY event_date DESC OFFSET ?)",
userId, maxEventsPerUser)

recalcEventCount(Seq(userId))
}

/**
* Получить список уведомлений для пользователя.
*
Expand Down

0 comments on commit 5849f7a

Please sign in to comment.