<commit_before>module ExercismWeb
  module Routes
    class Solutions < Core
      get '/code/:language/:slug/random' do |language, slug|
        please_login

        language, slug = language.downcase, slug.downcase

        problem = Problem.new(language, slug)

        unless current_user.nitpicker_on?(problem)
          flash[:notice] = "You'll have access to that page when you complete #{slug} in #{language}"
          redirect '/'
        end

        submission = Submission.random_completed_for(problem)
        total = Submission.completed_for(problem).count

        erb :"code/random", locals: {submission: submission, total: total}
      end
    end
  end
end<commit_msg>Add more context for difficult-to-reproduce exception<commit_after>module ExercismWeb
  module Routes
    class Solutions < Core
      get '/code/:language/:slug/random' do |language, slug|
        please_login

        language, slug = language.downcase, slug.downcase

        problem = Problem.new(language, slug)

        unless current_user.nitpicker_on?(problem)
          flash[:notice] = "You'll have access to that page when you complete #{slug} in #{language}"
          redirect '/'
        end

        submission = Submission.random_completed_for(problem)
        total = Submission.completed_for(problem).count

        if submission.problem.nil?
          # Need more info
          Bugsnag.notify("WARN: unknown problem for submission #{submission.key}")
          # try again
          redirect "/code/%s/%s/random" % [language, slug]
        end

        erb :"code/random", locals: {submission: submission, total: total}
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09607250755287008, 'fraction_numerical': 0.0, 'mean_word_length': 2.5844155844155843, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6245394', 'n_tokens_mistral': 472, 'n_tokens_neox': 451, 'n_words': 126}