Skip to content

Commit

Permalink
TRELLO-2537 : Adding logs
Browse files Browse the repository at this point in the history
  • Loading branch information
ssedoudbgouv committed Sep 28, 2024
1 parent 26e76cc commit 2aec65f
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions app/models/report/sampledata/SampleDataService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class SampleDataService(
logger.info("BEGIN Sample service creation")
for {
_ <- delete(List(proUser1, proUser2, proUser3, proUser4, proUser5))
_ = logger.info("DELETING previous data Done")
_ = logger.info(s"Creation proUser1 ${proUser1.id}")
_ <- createUser(proUser1)
_ = logger.info(s"Creation proUser2 ${proUser2.id}")
Expand Down Expand Up @@ -255,7 +256,7 @@ class SampleDataService(

private def delete(predefinedUsers: List[User]) = {
logger.info("DELETING previous data")
val o = predefinedUsers
predefinedUsers
.traverse { predefinedUser =>
for {
maybeUser <- userRepository.get(predefinedUser.id)
Expand All @@ -266,17 +267,9 @@ class SampleDataService(
s"Looking for companies link to company user ${predefinedUser.id} , found: ${companies.size}"
)
companyIds = companies.map(c => c.company.id)
reportList <- reportRepository
.getReports(
None,
ReportFilter(companyIds = companyIds),
None,
None
)
.map(_.entities.map(_.report.id))
reportList <- companyIds.flatTraverse(c => reportRepository.getReports(c))
_ = logger.info(s"Looking for reports link to company user ${predefinedUser.id}, found: ${reportList.size}")
_ <- reportList.traverse(reportAdminActionOrchestrator.deleteReport)

_ <- reportList.traverse(r => reportAdminActionOrchestrator.deleteReport(r.id))
websites <- websiteRepository.searchByCompaniesId(companies.map(_.company.id))
_ = logger.info(s"Looking for websites link to company user ${predefinedUser.id}, found: ${reportList.size}")
_ <- websites.map(_.id).traverse(websiteRepository.delete)
Expand All @@ -285,7 +278,6 @@ class SampleDataService(
_ = logger.info(s"Deletion done for company user ${predefinedUser.id}")
} yield ()
}
o.tap(_ => logger.info("DELETING previous data Done"))

}

Expand Down

0 comments on commit 2aec65f

Please sign in to comment.