Skip to content

Commit

Permalink
FFGR8-2715: fix sample data job
Browse files Browse the repository at this point in the history
  • Loading branch information
ssedoudbgouv committed Nov 16, 2024
1 parent e521da0 commit 4b8f75e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
5 changes: 2 additions & 3 deletions app/loader/SignalConsoApplicationLoader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -616,13 +616,12 @@ class SignalConsoComponents(
reportRepository,
companyAccessRepository,
reportAdminActionOrchestrator,
websiteRepository
websiteRepository,
eventRepository
)(
actorSystem
)

sampleDataService.genSampleData()

val sampleDataGenerationTask =
new SampleDataGenerationTask(actorSystem, sampleDataService, taskConfiguration, taskRepository)

Expand Down
5 changes: 4 additions & 1 deletion app/models/report/sampledata/SampleDataService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import play.api.Logging
import repositories.accesstoken.AccessTokenRepositoryInterface
import repositories.company.CompanyRepositoryInterface
import repositories.companyaccess.CompanyAccessRepositoryInterface
import repositories.event.EventRepositoryInterface
import repositories.report.ReportRepositoryInterface
import repositories.user.UserRepositoryInterface
import repositories.website.WebsiteRepositoryInterface
Expand All @@ -37,7 +38,8 @@ class SampleDataService(
reportRepository: ReportRepositoryInterface,
companyAccessRepository: CompanyAccessRepositoryInterface,
reportAdminActionOrchestrator: ReportAdminActionOrchestrator,
websiteRepository: WebsiteRepositoryInterface
websiteRepository: WebsiteRepositoryInterface,
eventRepository: EventRepositoryInterface
)(implicit system: ActorSystem)
extends Logging {

Expand Down Expand Up @@ -268,6 +270,7 @@ class SampleDataService(
reportList <- companyIds.flatTraverse(c => reportRepository.getReports(c))
_ = logger.info(s"Looking for reports link to company user ${predefinedUser.id}, found: ${reportList.size}")
_ <- reportList.traverse(r => reportAdminActionOrchestrator.deleteReport(r.id))
_ <- maybeUser.traverse(user => eventRepository.deleteByUserId(user.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 Down
7 changes: 7 additions & 0 deletions app/repositories/event/EventRepository.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ class EventRepository(
.delete
)

override def deleteByUserId(userId: UUID): Future[Int] = db
.run(
table
.filter(_.userId === userId)
.delete
)

override def deleteEngagement(uuidReport: UUID): Future[Int] = db
.run(
table
Expand Down
2 changes: 2 additions & 0 deletions app/repositories/event/EventRepositoryInterface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import scala.concurrent.Future

trait EventRepositoryInterface extends CRUDRepositoryInterface[Event] {

def deleteByUserId(userId: UUID): Future[Int]

def deleteByReportId(uuidReport: UUID): Future[Int]

def deleteEngagement(uuidReport: UUID): Future[Int]
Expand Down

0 comments on commit 4b8f75e

Please sign in to comment.