Sha256: 616448a40759528e350de53bf108f1125f991599fd9cb29ac42903231db3d2d5

Contents?: true

Size: 370 Bytes

Versions: 6

Compression:

Stored size: 370 Bytes

Contents

class Thing < ActiveRecord::Base
  include Concerns::Model::BaseThing
  
  def self.suggest(term)
    known_things = Thing.order(:name).where("name LIKE ?", "%#{term}%").limit(10).map do |t| 
      { id: t.id, name: t.name }
    end
    
    (known_things + Wikidata.search(term, known_things)).map do |item|
      item[:value] = item[:name]
      item
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
voluntary-0.7.1 app/models/thing.rb
voluntary-0.7.0 app/models/thing.rb
voluntary-0.6.0 app/models/thing.rb
voluntary-0.5.2 app/models/thing.rb
voluntary-0.5.1 app/models/thing.rb
voluntary-0.5.0 app/models/thing.rb