Skip to content

Instantly share code, notes, and snippets.

@penguinbroker
Last active August 29, 2015 14:16
Show Gist options
  • Save penguinbroker/8b94fd3db2f322e01821 to your computer and use it in GitHub Desktop.
Save penguinbroker/8b94fd3db2f322e01821 to your computer and use it in GitHub Desktop.
find broken sections
val sections = Await.result(ComponentRegistry.sectionDao.tableScan, 100.seconds)
sections map { section =>
val sectionId = section.getIdOrFail
val userSections = Await.result(ComponentRegistry.userSectionService.findInstructorsBySectionId(sectionId), 100.seconds)
val instructorIds = userSections.map( _.userId ).distinct
val allInstructors = Await.result(ComponentRegistry.institutionUserService.findByIds(instructorIds, section.institutionId), 100.seconds)
val instructors = allInstructors.filter(!_.isInactive)
instructors.find(_.getIdOrFail == section.instructorId) getOrElse {
println("--")
println("broken section")
println(sectionId)
val institution = Await.result(ComponentRegistry.institutionService.fetchById(section.institutionId), 10.seconds)
Await.result(ComponentRegistry.sectionEnrollmentService.enroll(institution, section.instructorId, sectionId, models.UserSectionRole.Instructor), 100.seconds)
}
Thread.sleep(10)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment