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

class CfThreadsController < ApplicationController
  load_and_authorize_resource

  before_filter :require_login, :only => [:edit, :update, :destroy]

  SHOW_THREADLIST  = "show_threadlist"
  SHOW_THREAD      = "show_thread"
  SHOW_NEW_THREAD  = "show_new_thread"
  NEW_THREAD       = "new_thread"
  NEW_THREAD_SAVED = "new_thread_saved"

  def index
    forum  = current_forum
    @page  = params[:p].to_i
    @limit = uconf('pagination', 50)
    @page  = 0 if @page < 0

    conditions = {}
    conditions[:forum_id] = forum.forum_id if forum
    conditions[:archived] = false if conf('use_archive')

    @threads = CfThread.
      preload(:messages, :forum).
      where(conditions).
      order('cforum.threads.created_at DESC').
      limit(@limit).
      offset(@limit * @page)

    if forum
      rslt = CfForum.connection.execute("SELECT cforum.counter_table_get_count('threads', " +
        current_forum.forum_id.to_s +
        ") AS cnt")
    else<commit_msg>preload owner, too<commit_after># -*- encoding: utf-8 -*-

class CfThreadsController < ApplicationController
  load_and_authorize_resource

  before_filter :require_login, :only => [:edit, :update, :destroy]

  SHOW_THREADLIST  = "show_threadlist"
  SHOW_THREAD      = "show_thread"
  SHOW_NEW_THREAD  = "show_new_thread"
  NEW_THREAD       = "new_thread"
  NEW_THREAD_SAVED = "new_thread_saved"

  def index
    forum  = current_forum
    @page  = params[:p].to_i
    @limit = uconf('pagination', 50)
    @page  = 0 if @page < 0

    conditions = {}
    conditions[:forum_id] = forum.forum_id if forum
    conditions[:archived] = false if conf('use_archive')

    @threads = CfThread.
      preload(:forum, :messages => :owner).
      where(conditions).
      order('cforum.threads.created_at DESC').
      limit(@limit).
      offset(@limit * @page)

    if forum
      rslt = CfForum.connection.execute("SELECT cforum.counter_table_get_count('threads', " +
        current_forum.forum_id.to_s +
        ") AS cnt")
    else
{'fraction_non_alphanumeric': 0.12076583210603829, 'fraction_numerical': 0.004909180166912126, 'mean_word_length': 3.219461697722567, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, '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': '398544', 'n_tokens_mistral': 710, 'n_tokens_neox': 669, 'n_words': 132}