Query cache: redo how sorts are determined for abstract queries.

Abstract queries being ones that don't have a postgres query backing
them.

This allows for different sorts to be returned based on the parameters
to the function rather than the sort being fixed at decoration time.
Query cache: allow non-thing first arguments.
Update controversy algorithm to take magnitude more into account.
Controversy: be defensive against negative ups/downs (bad data)