<commit_before>class AssetController < ApplicationController
  prepend_before_filter :fetch_asset, :only => :show
  prepend_before_filter :initialize_asset, :only => :create #maybe we can merge these two filters

  def show
    send_file(@asset.full_filename(@thumb), :type => @asset.content_type, :disposition => (@asset.image? ? 'inline' : 'attachment'))
  end

  def create
    if @asset.save
#      if params[:title] || params[:tag_list]
#        params[:page] = {:title => params[:title]}
#        @page = build_new_page
#        @page.data = @asset
#        @page.save
#      end
      return redirect_to page_url(@asset.page)
    end
  end

#  include Tool::ToolCreation
#  def get_groups
#    @asset.page.groups
#  end
#  def get_page_type
#    Tool::Asset
#  end

  protected

  def fetch_asset
    @thumb = nil
    @asset = Asset.find(params[:id], :include => ['pages', 'thumbnails']) if params[:id]
    @asset = @asset.versions[params[:version].to_i - 1] if params[:version]
    if @asset && @asset.image? && @asset.filename != "#{params[:filename]}.#{params[:format]}"
      thumb = @asset.thumbnails.detect {|a| a.filename == "#{params[:filename]}.#{params[:format]}"}
      render(:text => "Not found", :status => :not_found) and return unless thumb
      @thumb = thumb.thumbnail.to_sym
      @asset.create_or_update_thumbnail(@asset.full_filename,@thumb,Asset.attachment_options[:thumbnails][@thumb]) unless File.exists? thumb.full_filename
    end
    if @asset.is_public?
      @asset.update_access 
      redirect_to and return false
    end<commit_msg>minor: remove ruby warning<commit_after>class AssetController < ApplicationController
  prepend_before_filter :fetch_asset, :only => :show
  prepend_before_filter :initialize_asset, :only => :create #maybe we can merge these two filters

  def show
    send_file(@asset.full_filename(@thumb), :type => @asset.content_type, :disposition => (@asset.image? ? 'inline' : 'attachment'))
  end

  def create
    if @asset.save
#      if params[:title] || params[:tag_list]
#        params[:page] = {:title => params[:title]}
#        @page = build_new_page
#        @page.data = @asset
#        @page.save
#      end
      return redirect_to(page_url(@asset.page))
    end
  end

#  include Tool::ToolCreation
#  def get_groups
#    @asset.page.groups
#  end
#  def get_page_type
#    Tool::Asset
#  end

  protected

  def fetch_asset
    @thumb = nil
    @asset = Asset.find(params[:id], :include => ['pages', 'thumbnails']) if params[:id]
    @asset = @asset.versions[params[:version].to_i - 1] if params[:version]
    if @asset && @asset.image? && @asset.filename != "#{params[:filename]}.#{params[:format]}"
      thumb = @asset.thumbnails.detect {|a| a.filename == "#{params[:filename]}.#{params[:format]}"}
      render(:text => "Not found", :status => :not_found) and return unless thumb
      @thumb = thumb.thumbnail.to_sym
      @asset.create_or_update_thumbnail(@asset.full_filename,@thumb,Asset.attachment_options[:thumbnails][@thumb]) unless File.exists? thumb.full_filename
    end
    if @asset.is_public?
      @asset.update_access 
      redirect_to and return false
    end
{'fraction_non_alphanumeric': 0.14661177960734642, 'fraction_numerical': 0.0006333122229259025, 'mean_word_length': 3.779122541603631, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '2537282', 'n_tokens_mistral': 1012, 'n_tokens_neox': 991, 'n_words': 221}