Bug 1037658 

work around a Sequelize bug in findAndCountAll that counts rows from included tables
Move this and the other function out of this scope; they're being created on every request