Fix department codeflower N+1 issue