improve distinct_on

refs CNVS-16563

distinct_on returns a relation, and takes select from the relation
(and order becomes automatic)

test plan:
 * specs should pass
 * dashboard should load, and course menu should have data

Change-Id: I26c6068aaa4aa89c2626cdb8058f3aa9e50ff0fb
Reviewed-on: https://gerrit.instructure.com/43622
QA-Review: August Thornton <august@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>