Sha256: 19b8cac889df9c7688ea6be8b1cd146e4028963d44b084c24061aca4b9c497f6

Contents?: true

Size: 816 Bytes

Versions: 6

Compression:

Stored size: 816 Bytes

Contents

namespace "SensuDashboard", (exports) ->

  class exports.Matcher

    constructor: (options = {}) ->
      options = _.defaults(options, {
        threshold: 0.70
        sources: []
      })
      @sources = options.sources
      @threshold = options.threshold

    query: (query) ->
      results = []

      for source in @sources
        source.each (model) =>

          score = if model.validForQuery
            model.validForQuery(query, @threshold)
          else
            score = liquidMetal.score(model.get("name"), query)
            score if score > @threshold

          results.push({
            score: score
            model: model
          }) if score > 0

      results.sort((a,b) -> b.score - a.score)
      _.pluck(results, "model")

    addSource: (source) ->
      @sources.push(source)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sensu-dashboard-0.10.4 lib/sensu-dashboard/assets/javascripts/matcher.coffee
sensu-dashboard-0.10.3 lib/sensu-dashboard/assets/javascripts/matcher.coffee
sensu-dashboard-0.10.2 lib/sensu-dashboard/assets/javascripts/matcher.coffee
sensu-dashboard-0.10.1 lib/sensu-dashboard/assets/javascripts/matcher.coffee
sensu-dashboard-0.10.0 lib/sensu-dashboard/assets/javascripts/matcher.coffee
sensu-dashboard-0.9.9 lib/sensu-dashboard/assets/javascripts/matcher.coffee