Skip to content

Commit

Permalink
fix: do not archive limitless vigilance areas
Browse files Browse the repository at this point in the history
  • Loading branch information
maximeperrault committed Jan 20, 2025
1 parent c350bc3 commit b086511
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ interface IDBVigilanceAreaRepository : JpaRepository<VigilanceAreaModel, Int> {
"""
UPDATE vigilance_areas
SET is_archived = TRUE
WHERE computed_end_date IS NOT NULL AND computed_end_date < NOW() AND is_archived IS FALSE
WHERE computed_end_date IS NOT NULL
AND computed_end_date < NOW()
AND is_archived IS FALSE
AND is_at_all_times IS FALSE
""",
nativeQuery = true,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import fr.gouv.cacem.monitorenv.domain.entities.vigilanceArea.FrequencyEnum
import fr.gouv.cacem.monitorenv.domain.entities.vigilanceArea.ImageEntity
import fr.gouv.cacem.monitorenv.domain.entities.vigilanceArea.VigilanceAreaEntity
import fr.gouv.cacem.monitorenv.domain.entities.vigilanceArea.VisibilityEnum
import fr.gouv.cacem.monitorenv.domain.use_cases.vigilanceArea.fixtures.VigilanceAreaFixture
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
Expand Down Expand Up @@ -192,6 +193,20 @@ class JpaVigilanceAreaRepositoryITests : AbstractDBTests() {
assertThat(archivedVigilanceArea?.isArchived).isEqualTo(true)
}

@Test
@Transactional
fun `archive should not archive limitless vigilance areas`() {
// Given
val limitlessVigilanceArea =
VigilanceAreaFixture.aVigilanceAreaEntity().copy(id = null, isAtAllTimes = true)
val savedVigilanceArea = jpaVigilanceAreaRepository.save(limitlessVigilanceArea)
// When
jpaVigilanceAreaRepository.archiveOutdatedVigilanceAreas()
// Then
val archivedVigilanceArea = jpaVigilanceAreaRepository.findById(savedVigilanceArea.id!!)
assertThat(archivedVigilanceArea?.isArchived).isEqualTo(false)
}

@Test
fun `findAllByGeometry should return all vigilance areas that intersect the geometry `() {
// Given
Expand Down
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b086511

Please sign in to comment.