<commit_before>
class Rest::Models::HostsController < ::Rest::BaseController

  def index
    query = params[:q] || params[:query]
    if not query.blank? then
      hosts = Host.search(query, current_user)
    else
      hosts = Host.for_user(current_user)
    end
    restful hosts
  end

  def show
    restful Host.find(_id)
  end

  def update
    host = Host.find(_id)
    attrs = pick(:alias, :desc)
    attrs[:tag_list] = params[:tags]
    host.update_attributes(attrs)

    restful host
  end

  def destroy
    host = Host.find(_id)
    host.destroy
    host.agent.destroy if host.agent

    restful host
  end

  def update_facts
    host = Host.find(_id)
    Bixby::Inventory.new.update_facts(host)
    restful host
  end

  def update_check_config
    host = Host.find(_id)
    restful Bixby::Monitoring.new.update_check_config(host.agent)
  end

  def tags
    restful Host.all_tags(current_user)
  end

end<commit_msg>run update_check_config async in bg<commit_after>
class Rest::Models::HostsController < ::Rest::BaseController

  def index
    query = params[:q] || params[:query]
    if not query.blank? then
      hosts = Host.search(query, current_user)
    else
      hosts = Host.for_user(current_user)
    end
    restful hosts
  end

  def show
    restful Host.find(_id)
  end

  def update
    host = Host.find(_id)
    attrs = pick(:alias, :desc)
    attrs[:tag_list] = params[:tags]
    host.update_attributes(attrs)

    restful host
  end

  def destroy
    host = Host.find(_id)
    host.destroy
    host.agent.destroy if host.agent

    restful host
  end

  def update_facts
    host = Host.find(_id)
    Bixby::Inventory.new.update_facts(host)
    restful host
  end

  def update_check_config
    host = Host.find(_id)
    Bixby::Monitoring.defer.update_check_config(host.agent) # run in background
    restful true
  end

  def tags
    restful Host.all_tags(current_user)
  end

end
{'fraction_non_alphanumeric': 0.09119332985930172, 'fraction_numerical': 0.0, 'mean_word_length': 2.950617283950617, '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': '1879951', 'n_tokens_mistral': 660, 'n_tokens_neox': 637, 'n_words': 153}