<commit_before># frozen_string_literal: true

# create and edit Glossary terms
class GlossaryTermsController < ApplicationController
  before_action :login_required, except: [
    :index,
    :show_past,
    :show
  ]
  before_action :store_location, only: [:index, :show, :destroy]
  before_action :pass_query_params, only: [:destroy, :show_past]

  # ---------- Actions to Display data (index, show, etc.) ---------------------

  def index
    @glossary_terms = GlossaryTerm.all.order(:name)
  end

  def show
    @glossary_term = GlossaryTerm.find(params[:id].to_s)
    @canonical_url = glossary_term_url
    @layout = calc_layout_params
    @objects = @glossary_term.images
  end

  # ---------- Actions to Display forms -- (new, edit, etc.) -------------------

  def new
    @copyright_holder = @user.name
    @copyright_year = Time.now.utc.year
    @upload_license_id = @user.license_id
    @licenses = License.current_names_and_ids(@user.license)
  end

  def edit<commit_msg>Fix GlossaryTerm index n+1 problem<commit_after># frozen_string_literal: true

# create and edit Glossary terms
class GlossaryTermsController < ApplicationController
  before_action :login_required, except: [
    :index,
    :show_past,
    :show
  ]
  before_action :store_location, only: [:index, :show, :destroy]
  before_action :pass_query_params, only: [:destroy, :show_past]

  # ---------- Actions to Display data (index, show, etc.) ---------------------

  def index
    @glossary_terms = GlossaryTerm.includes(thumb_image: :image_votes).
                                   order(:name)
  end

  def show
    @glossary_term = GlossaryTerm.find(params[:id].to_s)
    @canonical_url = glossary_term_url
    @layout = calc_layout_params
    @objects = @glossary_term.images
  end

  # ---------- Actions to Display forms -- (new, edit, etc.) -------------------

  def new
    @copyright_holder = @user.name
    @copyright_year = Time.now.utc.year
    @upload_license_id = @user.license_id
    @licenses = License.current_names_and_ids(@user.license)
  end

  def edit
{'fraction_non_alphanumeric': 0.15104419621175327, 'fraction_numerical': 0.00048567265662943174, 'mean_word_length': 2.843283582089552, '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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7381509', 'n_tokens_mistral': 674, 'n_tokens_neox': 646, 'n_words': 147}