<commit_before>
namespace 'Bixby.model', (exports, top) ->

  class exports.Check extends Stark.Model

    urlRoot: ->
      s = "/rest/hosts/#{@host_id || @host.id}/checks"

    params: [ "host", "metric", { name: "check", set_id: true } ]

    url: ->
      s = super()
      if @metric_id?
        s += "?metric_id=" + @metric_id
      return s

    has_args: ->
      @get("args")? && !_.isEmpty(@get("args"))

    # Return args as a comma-separated string of "key = value" pairs
    args_str: (command, host) ->
     # if a command argument is provided then we get the nice formatted output...
      args = @get("args")
      if ! args
        return ""

      args_array = _.map(args, (val, key) ->
        s = if !command then key + " = " else command.get("options")[key]["name"] + " => "
        key_or_name_val = if !command then key else command.get("options")[key]["name"]
        if _.contains(["password", "<PASSWORD>", "pw"], key_or_name_val)
          s += "[hidden]"
        else
          s += if !command then val else val + "<br/>"
        return s
      )

      unless !command
        unless !host
          s = "Run check from host => "
          s += host.name()
          if (command.location == "remote" || command.location == "any")
             args_array.push s

      if !command then args_array.join(", ") else args_array.join(" ")


    # Get list of metrics of for this check (same check id)
    filter_metrics: (metrics) ->
      c = @
      _.sortBy(
        metrics.filter((m) -> m.get("check_id") == c.id),
        "id")<commit_msg>cleanup/simplify the Check.args_str() method<commit_after>
namespace 'Bixby.model', (exports, top) ->

  class exports.Check extends Stark.Model

    urlRoot: ->
      s = "/rest/hosts/#{@host_id || @host.id}/checks"

    params: [ "host", "metric", { name: "check", set_id: true } ]

    url: ->
      s = super()
      if @metric_id?
        s += "?metric_id=" + @metric_id
      return s

    has_args: ->
      @get("args")? && !_.isEmpty(@get("args"))

    # Return args as a comma-separated string of "key = value" pairs
    args_str: (command, host) ->
      # if a command argument is provided then we get the nice formatted output...
      args = @get("args")
      if ! args
        return ""

      args_array = _.map(args, (val, key) ->
        s = if command
          command.get("options")[key]["name"]
        else
          key
        s += " = "

        if _.contains(["password", "pass", "pw"], key)
          s += "[hidden]"
        else
          s += val

        return s
      )

      if command && host
        s = "Run check from host: "
        s += host.name()
        if (command.location == "remote" || command.location == "any")
           args_array.push s

      if command
        return args_array.join("<br/>")
      else
        return args_array.join(", ")


    # Get list of metrics of for this check (same check id)
    filter_metrics: (metrics) ->
      c = @
      _.sortBy(
        metrics.filter((m) -> m.get("check_id") == c.id),
        "id")
{'fraction_non_alphanumeric': 0.1588235294117647, 'fraction_numerical': 0.0, 'mean_word_length': 1.9892578125, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 24, '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': '5891078', 'n_tokens_mistral': 982, 'n_tokens_neox': 944, 'n_words': 275}