correct group by query
revert gemfile to support production site env