Skip to content

Commit

Permalink
Merge pull request #5655 from espoon-voltti/inactive-people-cleanup-f…
Browse files Browse the repository at this point in the history
…ixes

Ei yritetä poistaa inaktiivista huoltajaa tai lasta jolla on pedagoginen dokumentti
  • Loading branch information
reynders authored Sep 13, 2024
2 parents f5295d5 + 9072ec6 commit a075fb7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ import fi.espoo.evaka.messaging.upsertEmployeeMessageAccount
import fi.espoo.evaka.pis.service.blockGuardian
import fi.espoo.evaka.pis.service.deleteGuardianRelationship
import fi.espoo.evaka.pis.service.insertGuardian
import fi.espoo.evaka.shared.AssistanceNeedPreschoolDecisionId
import fi.espoo.evaka.shared.EmployeeId
import fi.espoo.evaka.shared.IncomeStatementId
import fi.espoo.evaka.shared.PedagogicalDocumentId
import fi.espoo.evaka.shared.PersonId
import fi.espoo.evaka.shared.dev.DevAssistanceNeedDecision
import fi.espoo.evaka.shared.dev.DevAssistanceNeedPreschoolDecision
Expand All @@ -34,6 +36,7 @@ import fi.espoo.evaka.shared.dev.DevEmployee
import fi.espoo.evaka.shared.dev.DevGuardian
import fi.espoo.evaka.shared.dev.DevIncomeStatement
import fi.espoo.evaka.shared.dev.DevParentship
import fi.espoo.evaka.shared.dev.DevPedagogicalDocument
import fi.espoo.evaka.shared.dev.DevPerson
import fi.espoo.evaka.shared.dev.DevPersonType
import fi.espoo.evaka.shared.dev.DevPlacement
Expand Down Expand Up @@ -316,6 +319,24 @@ class InactivePeopleCleanupIntegrationTest : PureJdbiTest(resetDbBeforeEach = tr
assertCleanedUpPeople(testDate, setOf())
}

@Test
fun `adult and child with pedagogical document is not cleaned up`() {
db.transaction { tx ->
tx.insert(testChild_1, DevPersonType.RAW_ROW)
val docId = PedagogicalDocumentId(UUID.randomUUID())
tx.insert(DevPedagogicalDocument(docId, testChild_1.id, "document"))
tx.insert(testAdult_1, DevPersonType.RAW_ROW)
tx.createUpdate {
sql(
"INSERT INTO pedagogical_document_read (person_id, pedagogical_document_id, read_at) VALUES (${bind(testAdult_1.id)}, ${bind(docId)}, ${bind(testDate)})"
)
}
.execute()
}

assertCleanedUpPeople(testDate, setOf())
}

@Test
fun `adult with received messages is cleaned up`() {
val now = HelsinkiDateTime.now()
Expand Down Expand Up @@ -448,8 +469,10 @@ class InactivePeopleCleanupIntegrationTest : PureJdbiTest(resetDbBeforeEach = tr
tx.insert(
DevEmployee(id = employeeId, firstName = "Firstname", lastName = "Supervisor")
)
val docId = AssistanceNeedPreschoolDecisionId(UUID.randomUUID())
tx.insertTestAssistanceNeedPreschoolDecision(
DevAssistanceNeedPreschoolDecision(
id = docId,
decisionNumber = 999,
childId = testChild_1.id,
form =
Expand Down Expand Up @@ -499,6 +522,12 @@ class InactivePeopleCleanupIntegrationTest : PureJdbiTest(resetDbBeforeEach = tr
unreadGuardianIds = emptySet(),
)
)
tx.createUpdate {
sql(
"INSERT INTO assistance_need_preschool_decision_guardian(assistance_need_decision_id, person_id) VALUES(${bind(docId)}, ${bind(testAdult_1.id)})"
)
}
.execute()
}

assertCleanedUpPeople(testDate, setOf())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ WITH people_with_no_archive_data AS (
EXCEPT
SELECT DISTINCT child_id FROM assistance_need_preschool_decision
EXCEPT
SELECT DISTINCT person_id FROM assistance_need_preschool_decision_guardian
EXCEPT
SELECT DISTINCT child_id FROM pedagogical_document
EXCEPT
SELECT DISTINCT person_id FROM pedagogical_document_read
EXCEPT
SELECT DISTINCT person_id FROM message_account
WHERE person_id IS NOT NULL
AND (
Expand Down

0 comments on commit a075fb7

Please sign in to comment.