Best way to get count of active contracts for a specific template

Please create separate topics for new questions.