Here it is. The two sites that I imported with this code were wildly different. I hope that someone finds it useful.
https://github.com/discourse/discourse/pull/5543