Fix Locations index in production by refactoring strange group by clause

Now there's a counter_cache on locations to keep track of how many
events each location has been used in.

Also fixed a couple other random test failures when using postgres.