Skip to content

Instantly share code, notes, and snippets.

private fun migratePeople(ctx: PplContext, newAccountId: Long, pushAppId: Long, options: PushMigrationOptions): PushAppMigrationResult {
var migratedPersons = 0L
var migratedDestinations = 0L
log.info("STARTING MIGRATION OF PERSONS FOR APPID $pushAppId")
personService.forEachPersonPaged(ctx, query(pushAppId)) { person ->
val destinations = findDestinationsForAppAndMsisdnEmail(person, pushAppId)
personMergeService.mergePerson(pplCtx(newAccountId), person.copy(id = null, destinations = destinations.map { it.copy(id = null) }, linkedIds = null), false)
destinations
.filter { it.type == DestinationType.PUSH }
.forEach { destinationService.deleteWithOptions(ctx, it._id, DeleteOneDestinationOptions(forceDeletePushDestinations = true)) }