From 153d4966eb778e36ace60564d49746962789c454 Mon Sep 17 00:00:00 2001 From: eletallbetagouv <107104509+eletallbetagouv@users.noreply.github.com> Date: Wed, 28 Aug 2024 11:50:40 +0200 Subject: [PATCH] TRELLO-2364 filter out deprecated events --- app/repositories/event/EventRepository.scala | 8 +++++++- app/repositories/event/EventTable.scala | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/repositories/event/EventRepository.scala b/app/repositories/event/EventRepository.scala index 4f5090dc4..12cb0d12d 100644 --- a/app/repositories/event/EventRepository.scala +++ b/app/repositories/event/EventRepository.scala @@ -32,12 +32,18 @@ class EventRepository( extends CRUDRepository[EventTable, Event] with EventRepositoryInterface { - override val table: TableQuery[EventTable] = EventTable.table + override val table = EventTable.table + import EventTable.fullTableIncludingDeprecated val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd") import dbConfig._ + override def create(element: Event): Future[Event] = db + .run( + fullTableIncludingDeprecated returning fullTableIncludingDeprecated += element + ) + override def deleteByReportId(uuidReport: UUID): Future[Int] = db .run( table diff --git a/app/repositories/event/EventTable.scala b/app/repositories/event/EventTable.scala index 44ca3c15f..a47c33d17 100644 --- a/app/repositories/event/EventTable.scala +++ b/app/repositories/event/EventTable.scala @@ -8,6 +8,7 @@ import utils.Constants import java.time.OffsetDateTime import java.util.UUID import repositories.PostgresProfile.api._ +import utils.Constants.ActionEvent.ACTIVATION_DOC_RETURNED class EventTable(tag: Tag) extends DatabaseTable[Event](tag, "events") { @@ -45,5 +46,9 @@ class EventTable(tag: Tag) extends DatabaseTable[Event](tag, "events") { } object EventTable { - val table = TableQuery[EventTable] + val fullTableIncludingDeprecated = TableQuery[EventTable] + + val table: Query[EventTable, EventTable#TableElementType, Seq] = fullTableIncludingDeprecated + // These events are from an old feature + .filter(_.action =!= ACTIVATION_DOC_RETURNED.value) }