maybe when we pull out self.submissions above, we could index them by user_id to create a hash of user_id => submission so that this lookup is fast.  i'm thinking something like replacing line 1405 with: submission_by_user = self.submissions.select(...).to_a.index_by(&:user_id)