<commit_before>class Api::ThreadsController < ApplicationController
  def show
    email = Email.find(params[:id])
    if email.original_email_id
      @emails = Email.includes(:email_labels).where(
        'original_email_id = ? OR id = ?',
        email.original_email_id, email.original_email_id
      ).order(date: :asc, time: :asc).to_a
    else
      @emails = Email.includes(:email_labels).where(
      'original_email_id = ? OR id = ?',
      email.id, email.id
      ).order(date: :asc, time: :asc).to_a
    end

    render :show
  end

  def destroy
    email = Email.find(params[:id])
    if email.original_email_id
      emails = Email.where(
        "original_email_id = ? OR id = ?",
        email.original_email_id, email.original_email_id
      ).destroy_all
    else
      emails = Email.where(original_email_id: email.id).destroy_all
      email.destroy
    end

    render json: emails
  end
end<commit_msg>change threads_controller#destroy to put to trash folder<commit_after>class Api::ThreadsController < ApplicationController
  def show
    email = Email.find(params[:id])
    if email.original_email_id
      @emails = Email.includes(:email_labels).where(
        'original_email_id = ? OR id = ?',
        email.original_email_id, email.original_email_id
      ).order(date: :asc, time: :asc).to_a
    else
      @emails = Email.includes(:email_labels).where(
      'original_email_id = ? OR id = ?',
      email.id, email.id
      ).order(date: :asc, time: :asc).to_a
    end

    render :show
  end

  def destroy
    email = Email.find(params[:id])
    if email.original_email_id
      emails = Email.where(
        "original_email_id = ? OR id = ?",
        email.original_email_id, email.original_email_id
      ).update_all(trash: true)
    else
      emails = Email.where(original_email_id: email.id).update_all(trash: true)
      email.update(trash: true)
    end

    render json: {}
  end
end
{'fraction_non_alphanumeric': 0.11312921639854696, 'fraction_numerical': 0.0, 'mean_word_length': 2.8406374501992033, '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': '6875713', 'n_tokens_mistral': 627, 'n_tokens_neox': 626, 'n_words': 129}