Sha256: 88f92df703d117ba30f9e45cde7658c719900649d48b11c4558300f9bc7a85b4

Contents?: true

Size: 1.26 KB

Versions: 34

Compression:

Stored size: 1.26 KB

Contents

class DigitalAssetLookupService

  def self.find_documents_by_fund_code(fund_codes)
    ids = fund_codes.collect {|c| term_id_from_fund_code(c)}
    DigitalAsset.product_in ids
  end

  def self.fund_code_from_id(taxonomy_id)
    TaxonomyTerm.term_id_is(taxonomy_id).try(:term_type).try([], 'FUND_CODE')
  end

  def self.term_id_from_fund_code(code) 
   term = TaxonomyTerm.fund_code_is(code)
   term.try(:first).try(:term_id)
  end

  def self.find_documents_by_query(arg_product_ids=nil, arg_content_type_ids=nil, arg_audience_ids=nil, finra=nil)
    product_ids = [] << arg_product_ids 
    product_ids.compact!
    product_ids.flatten!
    content_type_ids = [] << arg_content_type_ids
    content_type_ids.compact!
    content_type_ids.flatten!
    audience_ids = [] << arg_audience_ids
    audience_ids.compact!
    audience_ids.flatten!
    finra = finra || false
    query = {}
    query[:product_ids.in] = product_ids if !product_ids.blank?
    query[:'documents.content_type'.in] = content_type_ids if !content_type_ids.blank?
    query[:audiences.in] = audience_ids if !audience_ids.blank?
  
    digital_assets = DigitalAsset.where(query)
    digital_assets = digital_assets.select {|d| d.has_finra?} if finra
    digital_assets
  end

end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
daengine-0.4.0.3 app/service/digital_asset_lookup_service.rb
daengine-0.4.0.2 app/service/digital_asset_lookup_service.rb
daengine-0.4.0.1 app/service/digital_asset_lookup_service.rb
daengine-0.4.0.0 app/service/digital_asset_lookup_service.rb
daengine-0.3.9.9 app/service/digital_asset_lookup_service.rb
daengine-0.3.9.8 app/service/digital_asset_lookup_service.rb
daengine-0.3.9.7 app/service/digital_asset_lookup_service.rb
daengine-0.3.9.6 app/service/digital_asset_lookup_service.rb
daengine-0.3.9.5 app/service/digital_asset_lookup_service.rb
daengine-0.3.9.4 app/service/digital_asset_lookup_service.rb
daengine-0.3.9.3 app/service/digital_asset_lookup_service.rb
daengine-0.3.9.2 app/service/digital_asset_lookup_service.rb
daengine-0.3.9.1 app/service/digital_asset_lookup_service.rb
daengine-0.3.9 app/service/digital_asset_lookup_service.rb
daengine-0.3.8.4 app/service/digital_asset_lookup_service.rb
daengine-0.3.8.3 app/service/digital_asset_lookup_service.rb
daengine-0.3.8.2 app/service/digital_asset_lookup_service.rb
daengine-0.3.8.1 app/service/digital_asset_lookup_service.rb
daengine-0.3.8 app/service/digital_asset_lookup_service.rb
daengine-0.3.7.8 app/service/digital_asset_lookup_service.rb