<commit_before># app/controllers/request_game_controller.rb:
# The 'categorise old requests' game
#
# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
# Email: <EMAIL>; WWW: http://www.mysociety.org/

class RequestGameController < ApplicationController

    def play
        session[:request_game] = Time.now

        @missing = InfoRequest.count_old_unclassified(:conditions => ["prominence = 'normal'"])
        @total = InfoRequest.count
        @done = @total - @missing
        @percentage = (@done.to_f / @total.to_f * 10000).round / 100.0
        @requests = InfoRequest.get_random_old_unclassified(3, :conditions => ["prominence = 'normal'"])

        if @missing == 0
            flash[:notice] = _('<p>All done! Thank you very much for your help.</p><p>There are <a href="{{helpus_url}}">more things you can do</a> to help {{site_name}}.</p>',
                :helpus_url => help_credits_path+"#helpus",
                :site_name => site_name)
        end<commit_msg>Reduce N+1 queries in RequestGameController#play<commit_after># app/controllers/request_game_controller.rb:
# The 'categorise old requests' game
#
# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
# Email: <EMAIL>; WWW: http://www.mysociety.org/

class RequestGameController < ApplicationController

    def play
        session[:request_game] = Time.now

        @missing = InfoRequest.count_old_unclassified(:conditions => ["prominence = 'normal'"])
        @total = InfoRequest.count
        @done = @total - @missing
        @percentage = (@done.to_f / @total.to_f * 10000).round / 100.0
        @requests = InfoRequest.includes(:public_body, :user).get_random_old_unclassified(3, :conditions => ["prominence = 'normal'"])


        if @missing == 0
            flash[:notice] = _('<p>All done! Thank you very much for your help.</p><p>There are <a href="{{helpus_url}}">more things you can do</a> to help {{site_name}}.</p>',
                :helpus_url => help_credits_path+"#helpus",
                :site_name => site_name)
        end
{'fraction_non_alphanumeric': 0.1385658914728682, 'fraction_numerical': 0.015019379844961241, 'mean_word_length': 3.248971193415638, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3508472', 'n_tokens_mistral': 660, 'n_tokens_neox': 610, 'n_words': 154}