How to perform a group count query on a postgresql array column