Sha256: 2f79f612b48e120aa48b63bc6251c2c20f8896963da595df3adce42b09bee6b2
Contents?: true
Size: 1.44 KB
Versions: 3
Compression:
Stored size: 1.44 KB
Contents
# frozen_string_literal: true require "algolia" require "relaton_bsi/hit" module RelatonBsi # Page of hit collection. class HitCollection < RelatonBib::HitCollection DOMAIN = "https://shop.bsigroup.com" # @param ref [String] # @param year [String] def initialize(ref, year = nil) super ref, year config = Algolia::Search::Config.new( application_id: "575YE157G9", api_key: "a057b4e74099445df2eddb7940828a10", ) client = Algolia::Search::Client.new config, logger: ::Logger.new($stderr) index = client.init_index "shopify_products" resp = index.search text # , facetFilters: "product_type:standard" @array = hits resp[:hits] end private # @param hits [Array<Hash>] # @return [Array<RelatonBsi::Hit>] def hits(hits) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize hits.map do |h| code = h[:meta][:global][:primaryDesignator] .sub(/\s(?:LOOSELEAF|\(A5 LAMINATED\)|-\sTC$)/, "") Hit.new( { code: code, title: h[:title], url: h[:handle], date: h[:meta][:global][:publishedDate], publisher: h[:meta][:global][:publisher], status: h[:meta][:global][:status], ics: h[:meta][:global][:icsCodesAlgoliaStringArray], doctype: h[:product_type], }, self ) end.sort_by { |h| h.hit[:date] }.reverse end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
relaton-bsi-1.10.1 | lib/relaton_bsi/hit_collection.rb |
relaton-bsi-1.10.0 | lib/relaton_bsi/hit_collection.rb |
relaton-bsi-1.9.5 | lib/relaton_bsi/hit_collection.rb |