<commit_before># frozen_string_literal: true

class PostsController < ApplicationController
  protect_from_forgery except: [:create]
  before_action :check_if_smokedetector, only: :create
  before_action :set_post, only: %i[needs_admin feedbacksapi reindex_feedback cast_spam_flag delete_post]
  before_action :authenticate_user!, only: %i[reindex_feedback cast_spam_flag]
  before_action :verify_developer, only: %i[reindex_feedback delete_post]
  before_action :verify_reviewer, only: [:feedback]

  def show
    begin
      @post = Post.joins('LEFT JOIN `sites` ON `sites`.`id` = `posts`.`site_id`')
                  .joins(:reasons)
                  .includes(:feedbacks)
                  .select(Arel.sql('posts.*, sites.site_logo, SUM(reasons.weight) AS reason_weight'))
                  .find(params[:id])
    rescue
      @post = Post.find params[:id]
    end

    @is_review_item = false

    not_found if @post&.id.nil?
  end

  # Render bodies on-demand for fancy expanding rows<commit_msg>Small fix for github action tests<commit_after># frozen_string_literal: true

class PostsController < ApplicationController
  protect_from_forgery except: [:create]
  before_action :check_if_smokedetector, only: :create
  before_action :set_post, only: %i[needs_admin feedbacksapi reindex_feedback cast_spam_flag delete_post]
  before_action :authenticate_user!, only: %i[reindex_feedback cast_spam_flag]
  before_action :verify_developer, only: %i[reindex_feedback delete_post]
  before_action :verify_reviewer, only: [:feedback]

  def show
    begin
      @post = Post.joins('LEFT JOIN `sites` ON `sites`.`id` = `posts`.`site_id`')
                  .joins(:reasons)
                  .includes(:feedbacks)
                  .select(Arel.sql('posts.*, sites.site_logo, SUM(reasons.weight) AS reason_weight'))
                  .find(params[:id])
    rescue # rubocop:disable Lint/HandleExceptions
    end
    @post = Post.find params[:id] if @post&.id.nil?

    @is_review_item = false

    not_found if @post&.id.nil?
  end

  # Render bodies on-demand for fancy expanding rows
{'fraction_non_alphanumeric': 0.10354745925215723, 'fraction_numerical': 0.0, 'mean_word_length': 3.658482142857143, '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': '6182834', 'n_tokens_mistral': 696, 'n_tokens_neox': 652, 'n_words': 150}