Skip to content

Commit

Permalink
TRELLO-2537 : improve deletion script
Browse files Browse the repository at this point in the history
  • Loading branch information
ssedoudbgouv committed Sep 28, 2024
1 parent 6a595f9 commit dc92a95
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
5 changes: 2 additions & 3 deletions app/loader/SignalConsoApplicationLoader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ import repositories.website.WebsiteRepositoryInterface
import services._
import services.antivirus.AntivirusService
import services.antivirus.AntivirusServiceInterface
import services.emails.BaseEmail
import services.emails.MailRetriesService
import services.emails.MailService
import services.emails.MailServiceInterface
Expand Down Expand Up @@ -249,7 +248,7 @@ class SignalConsoComponents(
amazonBucketName = applicationConfiguration.amazonBucketName
)

def s3Service: S3ServiceInterface = new S3Service()
val s3Service: S3ServiceInterface = new S3Service()

// Actor
val antivirusScanActor: typed.ActorRef[AntivirusScanActor.ScanCommand] = actorSystem.spawn(
Expand Down Expand Up @@ -390,7 +389,7 @@ class SignalConsoComponents(

val emailNotificationOrchestrator = new EmailNotificationOrchestrator(mailService, subscriptionRepository)

def buildReportOrchestrator(emailService: MailServiceInterface) = new ReportOrchestrator(
private def buildReportOrchestrator(emailService: MailServiceInterface) = new ReportOrchestrator(
emailService,
reportConsumerReviewOrchestrator,
reportRepository,
Expand Down
21 changes: 11 additions & 10 deletions app/models/report/sampledata/SampleDataService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,13 @@ class SampleDataService(
}
.flatMap(_ => userRepository.updatePassword(user.id, password = "test"))

private def delete(users: List[User]) =
users.traverse { u =>
private def delete(predefinedUsers: List[User]) =
predefinedUsers.traverse { predefinedUser =>
for {
companies <- companyAccessRepository.fetchCompaniesWithLevel(u)
sirets = companies.map(_.company.siret.value)
maybeUser <- userRepository.get(predefinedUser.id)
maybeCompany <- maybeUser.traverse(user => companyAccessRepository.fetchCompaniesWithLevel(user))
companies = maybeCompany.getOrElse(List.empty)
sirets = companies.map(c => c.company.siret.value)
reportList <- reportRepository
.getReports(
None,
Expand All @@ -207,12 +209,11 @@ class SampleDataService(
None
)
.map(_.entities.map(_.report.id))
_ <- reportList.traverse(reportAdminActionOrchestrator.deleteReport)
companies <- companyAccessRepository.fetchCompaniesWithLevel(u)
websites <- websiteRepository.searchByCompaniesId(companies.map(_.company.id))
_ <- websites.map(_.id).traverse(websiteRepository.delete)
_ <- companies.traverse(c => companyRepository.delete(c.company.id))
_ <- userRepository.hardDelete(u.id)
_ <- reportList.traverse(reportAdminActionOrchestrator.deleteReport)
websites <- websiteRepository.searchByCompaniesId(companies.map(_.company.id))
_ <- websites.map(_.id).traverse(websiteRepository.delete)
_ <- companies.traverse(c => companyRepository.delete(c.company.id))
_ <- maybeUser.traverse(user => userRepository.hardDelete(user.id))
} yield ()
}

Expand Down

0 comments on commit dc92a95

Please sign in to comment.