<commit_before>class AgentsController < ApplicationController
  before_action :init_agent, only: [:show, :manage, :command, :raw_log, :edit_config, :update_config, :log_tail]


  def index
    @items = Agent.w_not_deleted.order("created_at desc").all
  end

  def log_tail
    limit = (params[:limit] || 10).to_i
    @logs = file_tail(@agent.log_path, limit) if @agent
    render json: @logs
  end

  def show

  end

  def new
    
  end

  def manage

  end

  def raw_log
    send_data @agent.log, type: "application/octet-stream", filename: File.basename(@agent.log_path)
  end

  def edit_config

  end

  def update_config
    @agent.update_config(params[:config])
    redirect_to manage_agent_path(@agent)
  end

  def command

    # input
    @cmd = params[:cmd]

    # work
    @res = Dataenchilada::Agents::Manager.do_command(@agent, @cmd)<commit_msg>log path fixed<commit_after>class AgentsController < ApplicationController
  before_action :init_agent, only: [:show, :manage, :command, :raw_log, :edit_config, :update_config, :log_tail]


  def index
    @items = Agent.w_not_deleted.order("created_at desc").all
  end

  def log_tail
    limit = (params[:limit] || 10).to_i
    @logs = file_tail(@agent.app_log_path, limit) if @agent
    render json: @logs
  end

  def show

  end

  def new
    
  end

  def manage

  end

  def raw_log
    send_data @agent.log, type: "application/octet-stream", filename: File.basename(@agent.app_log_path)
  end

  def edit_config

  end

  def update_config
    @agent.update_config(params[:config])
    redirect_to manage_agent_path(@agent)
  end

  def command

    # input
    @cmd = params[:cmd]

    # work
    @res = Dataenchilada::Agents::Manager.do_command(@agent, @cmd)
{'fraction_non_alphanumeric': 0.10860774119006354, 'fraction_numerical': 0.002310803004043905, 'mean_word_length': 3.545931758530184, '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': '2253634', 'n_tokens_mistral': 625, 'n_tokens_neox': 585, 'n_words': 139}