submission_count can either be a number or a function

depending on where it is called from. Within the template, we use a subquery to set the submission_count while normal cases use it as a function - fixes #1122