Add periodic_count_all method to model mixin
Fix query bug on count: window function should do sum of count and not count of count
Add performance tests