performance: Use joins for the castle_gate_queries

The subselect is faster if you enumerate all castles one has access to.
However since we changed the UI to not list ALL groups or ALL users anymore but
only allow search the set of castles will always be limited.
In this case the join performs a LOT better. In particular it's performance
improves if the conditions become more strict, while the subqueries performance
becomes worth.
make pagination work again in groups directory
work around accumulating select values

when applying with_access to an association the select values of that
association and the DESTINCT from with_access will be combined into an
invalid query.

I tried to work around this by using only_select inside the definition
of with_access. However with_access is (and needs to be) a scope so it
will get applied in addition to the existing scope which still includes
the select_value. In the relation merge the select values will be joined
again.

So instead we now ensure there is only the DISTINCT select in a custom
method for the group.users association. It seems like this is the only
association with_access is applied to.
we also apply with_access to group.real_committees
Merge pull request #52 from azul/performance/castle-gates-with-join

Performance/castle gates with join