<commit_before># -*- coding: utf-8 -*-

class CfThreads::InvisibleController < ApplicationController
  authorize_controller { authorize_user }

  SHOW_INVISIBLE_THREADLIST = "show_invisible_threadlist"

  def list_invisible_threads
    @limit = conf('pagination').to_i

    order = uconf('sort_threads')
    case order
    when 'ascending'
      order = 'threads.created_at ASC'
    when 'newest-first'
      order = 'threads.latest_message DESC'
    else
      order = 'threads.created_at DESC'
    end


    @threads = CfThread.
               preload(:forum, messages: [:owner, :tags, {votes: :voters}]).
               includes(messages: :owner).
               joins('INNER JOIN invisible_threads iv ON iv.thread_id = threads.thread_id').
               where('iv.user_id = ?', current_user.user_id).
               where(deleted: false, messages: {deleted: false}).
               order(order).page(params[:page]).per(@limit)

    @threads.each do |thread|
      sort_thread(thread)
    end

    ret = notification_center.notify(SHOW_INVISIBLE_THREADLIST, @threads)

    unless ret.include?(:redirected)
      respond_to do |format|
        format.html
        format.json { render @threads }
      end
    end
  end

  def unhide_thread
    @thread, @id = get_thread

    mark_invisible(current_user, @thread)

    redirect_to cf_return_url(@thread),
                notice: t('plugins.invisible_threads.thread_marked_visible')
  end

  def hide_thread
    @thread, @id = get_thread

    mark_invisible(current_user, @thread)<commit_msg>fix: fixed typo to unhide threads again<commit_after># -*- coding: utf-8 -*-

class CfThreads::InvisibleController < ApplicationController
  authorize_controller { authorize_user }

  SHOW_INVISIBLE_THREADLIST = "show_invisible_threadlist"

  def list_invisible_threads
    @limit = conf('pagination').to_i

    order = uconf('sort_threads')
    case order
    when 'ascending'
      order = 'threads.created_at ASC'
    when 'newest-first'
      order = 'threads.latest_message DESC'
    else
      order = 'threads.created_at DESC'
    end


    @threads = CfThread.
               preload(:forum, messages: [:owner, :tags, {votes: :voters}]).
               includes(messages: :owner).
               joins('INNER JOIN invisible_threads iv ON iv.thread_id = threads.thread_id').
               where('iv.user_id = ?', current_user.user_id).
               where(deleted: false, messages: {deleted: false}).
               order(order).page(params[:page]).per(@limit)

    @threads.each do |thread|
      sort_thread(thread)
    end

    ret = notification_center.notify(SHOW_INVISIBLE_THREADLIST, @threads)

    unless ret.include?(:redirected)
      respond_to do |format|
        format.html
        format.json { render @threads }
      end
    end
  end

  def unhide_thread
    @thread, @id = get_thread

    mark_visible(current_user, @thread)

    redirect_to cf_return_url(@thread),
                notice: t('plugins.invisible_threads.thread_marked_visible')
  end

  def hide_thread
    @thread, @id = get_thread

    mark_invisible(current_user, @thread)
{'fraction_non_alphanumeric': 0.1050771208226221, 'fraction_numerical': 0.0006426735218508997, 'mean_word_length': 2.8290282902829027, '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': '4548989', 'n_tokens_mistral': 981, 'n_tokens_neox': 937, 'n_words': 199}