<commit_before>define [
  'jquery'
  'underscore'
  'backbone'
  'hbs!templates/dashboard'
  'cs!views/detail'
], ($, _, Backbone, tmpl, MetricDetailView) ->
  class MetricDashboardView extends Backbone.View
    tagName: 'div'
    className: 'dash'
    template: tmpl

    events:
      "click":    "details"

    initialize: (attributes)->
      @row = attributes.row
      @span = "span" + attributes.span

    render: ->
      data = @model.attributes

      if data.format == '%'
        data.formatted_value = data.value + '%'
      else
        data.formatted_value = data.value

      if data.status > 0
        data.status_class = 'btn-success'
      else if data.status == 0
        data.status_class = 'btn-warning'
      else if data.status < 0
        data.status_class = 'btn-danger'
      else
        data.status_class = 'btn-inverse'

      @$el.addClass(@span)
      @$el.html(@template(@model.attributes))
      @row.$el.append(@el)

    details: ->
      detail = new MetricDetailView(model: @model)
      detail.render()<commit_msg>format value with commas<commit_after>define [
  'jquery'
  'underscore'
  'backbone'
  'hbs!templates/dashboard'
  'cs!views/detail'
], ($, _, Backbone, tmpl, MetricDetailView) ->
  class MetricDashboardView extends Backbone.View
    tagName: 'div'
    className: 'dash'
    template: tmpl

    events:
      "click":    "details"

    initialize: (attributes)->
      @row = attributes.row
      @span = "span" + attributes.span

    render: ->
      data = @model.attributes

      if data.format == '%'
        data.formatted_value = data.value + '%'
      else
        data.formatted_value = @formatNumber(data.value)

      if data.status > 0
        data.status_class = 'btn-success'
      else if data.status == 0
        data.status_class = 'btn-warning'
      else if data.status < 0
        data.status_class = 'btn-danger'
      else
        data.status_class = 'btn-inverse'

      @$el.addClass(@span)
      @$el.html(@template(@model.attributes))
      @row.$el.append(@el)

    formatNumber: (num) ->
      parts = num.toString().split(".")
      parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",")

      return parts.join(".")


    details: ->
      detail = new MetricDetailView(model: @model)
      detail.render()
{'fraction_non_alphanumeric': 0.1456607064980375, 'fraction_numerical': 0.0039249890972525075, 'mean_word_length': 2.3884785819793204, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 14, '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': '4815055', 'n_tokens_mistral': 762, 'n_tokens_neox': 733, 'n_words': 146}