This is a fairly comprehensive visit to the functionality needed by rain's spreadsheet. This is a pretty good improvement on the database query work needed to produce the resulting json; resulting in some pretty nice performance improvements on some queries, and negligible performance changes on others (but still a reduction in work).
There's also a small bugfix in here regarding the rain/prices
endpoint: Previously, the code appeared to assume that a CX entry only exists if it is found in the AI1
CX. So anything that was not scanned from AI1 would be missing in the result, such as AEN (at time of writing). The changes here remove that assumption, as well as making the database do lighter work through multiple queries instead of one very large union/join.