Last active
August 29, 2015 14:16
-
-
Save penguinbroker/8b94fd3db2f322e01821 to your computer and use it in GitHub Desktop.
find broken sections
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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