move query build based on the innings filter into it's own function