There's a lot of waiting involved in making chai so I decided to work on porting another report from the old Typica code base into the new one. The old code for this one takes a working but naive approach that involves far too many database queries. I've cut that down to 2 queries with a bit of client side processing combining the results. It's likely possible to cut it back to 1 query with exactly what I need, but I'm not confident that I would understand it later.