refactoring tickets_summary_query in dashboard helper