<commit_before>class Projects::TestCasesController < BaseProjectController
  layout 'card-full-height', only: [:index]
  before_action { @navbar = "cases" }
  before_action -> { @project = current_project }
  authorize_resource :project
  load_and_authorize_resource :folder
  load_and_authorize_resource :platform
  load_and_authorize_resource through: :project

  def index
    @default_cases_url_options = request.query_parameters
    test_cases_scope = @test_cases.available
    test_cases_scope = test_cases_scope.where_exists(Platform.connect_test_cases.where(id: @platform)) if @platform
    @test_cases = @test_cases.where(folder_id: @folder.subtree) if @folder
    @test_cases = @test_cases.page(params[:page])

    @folders = @project.folders.ranked

    test_cases_counts = test_cases_scope.group(:folder_id).count
    @folder_test_cases_counts = Folder.descendants_with_self_counts(@folders, test_cases_counts)
  end

  def new
  end

  def create
    @test_case.save
    respond_with @test_case, location: -> { ok_url_or_default([@project, TestCase]) }
  end

  def edit
  end

  def update
    @test_case.update(test_case_params)
    respond_with @test_case, location: -> { ok_url_or_default([@project, TestCase]) }
  end

  def destroy
    @test_case.archive
    respond_with @test_case, location: -> { ok_url_or_default([@project, TestCase]) }
  end

protected
  def test_case_params
    params.fetch(:test_case, {}).permit(:title, :content, :folder_id, platform_ids: [])
  end
end
<commit_msg>Fix bug archived test case is not hidden<commit_after>class Projects::TestCasesController < BaseProjectController
  layout 'card-full-height', only: [:index]
  before_action { @navbar = "cases" }
  before_action -> { @project = current_project }
  authorize_resource :project
  load_and_authorize_resource :folder
  load_and_authorize_resource :platform
  load_and_authorize_resource through: :project

  def index
    @default_cases_url_options = request.query_parameters
    @test_cases = @test_cases.available
    test_cases_scope = @test_cases
    test_cases_scope = @test_cases.where_exists(Platform.connect_test_cases.where(id: @platform)) if @platform
    @test_cases = @test_cases.where(folder_id: @folder.subtree) if @folder
    @test_cases = @test_cases.page(params[:page])

    @folders = @project.folders.ranked

    test_cases_counts = test_cases_scope.group(:folder_id).count
    @folder_test_cases_counts = Folder.descendants_with_self_counts(@folders, test_cases_counts)
  end

  def new
  end

  def create
    @test_case.save
    respond_with @test_case, location: -> { ok_url_or_default([@project, TestCase]) }
  end

  def edit
  end

  def update
    @test_case.update(test_case_params)
    respond_with @test_case, location: -> { ok_url_or_default([@project, TestCase]) }
  end

  def destroy
    @test_case.archive
    respond_with @test_case, location: -> { ok_url_or_default([@project, TestCase]) }
  end

protected
  def test_case_params
    params.fetch(:test_case, {}).permit(:title, :content, :folder_id, platform_ids: [])
  end
end

{'fraction_non_alphanumeric': 0.10026041666666667, 'fraction_numerical': 0.0, 'mean_word_length': 4.9210019267822736, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '3864139', 'n_tokens_mistral': 1037, 'n_tokens_neox': 1014, 'n_words': 191}