<commit_before>module Backend
  class MapLayersController < Backend::BaseController
    manage_restfully except: :index, identifier: :name

    respond_to :json, only: %i[toggle star]

    def index
      @map_layers = MapLayer.order('nature, by_default DESC, enabled DESC, name')
      @bounds = CultivableZone.first ? CultivableZone.first.shape_centroid : [44.8423142, -0.5988415]
    end

    def load
      begin
        MapLayer.load_defaults
        redirect_to params[:redirect] || { action: :index }
      rescue 
        notify_error :locking_vesrsion_error
        redirect_to params[:redirect] || { action: :index }
      end
    end

    def toggle
      return head :forbidden unless m = MapLayer.find_by(id: params[:id])<commit_msg>Error key typo fixing + Scoping rescue<commit_after>module Backend
  class MapLayersController < Backend::BaseController
    manage_restfully except: :index, identifier: :name

    respond_to :json, only: %i[toggle star]

    def index
      @map_layers = MapLayer.order('nature, by_default DESC, enabled DESC, name')
      @bounds = CultivableZone.first ? CultivableZone.first.shape_centroid : [44.8423142, -0.5988415]
    end

    def load
      begin
        MapLayer.load_defaults
        redirect_to params[:redirect] || { action: :index }
      rescue ActiveRecord::StaleObjectError
        notify_error :locking_version_error
        redirect_to params[:redirect] || { action: :index }
      end
    end

    def toggle
      return head :forbidden unless m = MapLayer.find_by(id: params[:id])
{'fraction_non_alphanumeric': 0.09120310478654592, 'fraction_numerical': 0.02199223803363519, 'mean_word_length': 3.2383561643835614, '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': '5209660', 'n_tokens_mistral': 495, 'n_tokens_neox': 457, 'n_words': 117}