User metrics processing with ruby instead of arel

This change is in preparation for segmenting users into licensing and non-licensing, for which the arel approach gets too hairy and unreadable.

/cc @vinayvinay