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

class CfArchiveController < ApplicationController
  authorize_action([:years]) { authorize_forum(permission: :read?) }

  include TagsHelper
  include ThreadsHelper

  SHOW_ARCHIVE_THREADLIST  = "show_archive_threadlist"

  def years
    @first_year = CfThread.order('created_at ASC').limit(1).first.created_at.year
    @last_year = CfThread.order('created_at DESC').limit(1).first.created_at.year
  end

  def year
    tmzone = Time.zone.parse(params[:year] + '-12-31 00:00:00')
    first_month = CfThread.where("EXTRACT(year FROM created_at + INTERVAL '? seconds') = ?", tmzone.utc_offset, params[:year]).
                  order('created_at ASC').
                  limit(1).first.created_at
    last_month = CfThread.where("EXTRACT(year FROM created_at + INTERVAL '? seconds') = ?", tmzone.utc_offset, params[:year]).
                 order('created_at DESC').
                 limit(1).first.created_at

    @months = []<commit_msg>fix: respect current_forum when set<commit_after># -*- encoding: utf-8 -*-

class CfArchiveController < ApplicationController
  authorize_action([:years]) { authorize_forum(permission: :read?) }

  include TagsHelper
  include ThreadsHelper

  SHOW_ARCHIVE_THREADLIST  = "show_archive_threadlist"

  def years
    @first_year = CfThread.order('created_at ASC').limit(1)
    @last_year = CfThread.order('created_at DESC').limit(1)

    unless current_forum.blank?
      @first_year = @first_year.where(forum_id: current_forum.forum_id)
      @last_year = @last_year.where(forum_id: current_forum.forum_id)
    end

    @first_year = @first_year.first.created_at.year
    @last_year = @last_year.first.created_at.year
  end

  def year
    tmzone = Time.zone.parse(params[:year] + '-12-31 00:00:00')
    first_month = CfThread.where("EXTRACT(year FROM created_at + INTERVAL '? seconds') = ?", tmzone.utc_offset, params[:year]).
                  order('created_at ASC').
                  limit(1)
    last_month = CfThread.where("EXTRACT(year FROM created_at + INTERVAL '? seconds') = ?", tmzone.utc_offset, params[:year]).
                 order('created_at DESC').
                 limit(1)

    if current_forum
      first_month = first_month.where(forum_id: current_forum.forum_id)
      last_month = last_month.where(forum_id: current_forum.forum_id)
    end

    first_month = first_month.first.created_at
    last_month = last_month.first.created_at

    @months = []
{'fraction_non_alphanumeric': 0.12433754586220953, 'fraction_numerical': 0.01222992254382389, 'mean_word_length': 3.478102189781022, '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': '5987909', 'n_tokens_mistral': 852, 'n_tokens_neox': 782, 'n_words': 136}