<commit_before>class Data::BaseController < ApplicationController
  layout 'data'
  before_filter :initialize_gql

  authorize_resource :class => false

  def redirect
    redirect_to data_root_path(:api_scenario_id => params[:api_scenario_id])
  end

  protected

    def initialize_gql
      api_scenario_id = params[:api_scenario_id] ||= 'latest'

      if api_scenario_id == 'latest'
        @api_scenario = Scenario.last
      else
        @api_scenario = Scenario.find(params[:api_scenario_id])
      end
      @gql = @api_scenario.gql(prepare: true)
    end
end
<commit_msg>Recover when a scenario uses a deleted dataset<commit_after>class Data::BaseController < ApplicationController
  layout 'data'
  before_filter :initialize_gql

  authorize_resource :class => false

  def redirect
    redirect_to data_root_path(:api_scenario_id => params[:api_scenario_id])
  end

  protected

    def initialize_gql
      api_scenario_id = params[:api_scenario_id] ||= 'latest'

      if api_scenario_id == 'latest'
        @api_scenario = Scenario.last
      else
        @api_scenario = Scenario.find(params[:api_scenario_id])
      end
      @gql = @api_scenario.gql(prepare: true)
    rescue Atlas::DocumentNotFoundError => ex
      if ex.message.match(/could not find a dataset with the key/i)
        scenario = Scenario.create(
          Scenario.default_attributes.merge(source: 'ETEngine Admin UI'))

        redirect_to "/data/#{ scenario.id }"
      else
        raise ex
      end
    end
end

{'fraction_non_alphanumeric': 0.08715901530272788, 'fraction_numerical': 0.0, 'mean_word_length': 3.30945558739255, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, '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': '5816947', 'n_tokens_mistral': 477, 'n_tokens_neox': 466, 'n_words': 104}