Class: DigitalAssetLookupService
- Inherits:
-
Object
- Object
- DigitalAssetLookupService
- Defined in:
- app/service/digital_asset_lookup_service.rb
Class Method Summary collapse
- .find_documents_by_fund_code(fund_codes) ⇒ Object
- .find_documents_by_fund_code_and_content_type(fund_codes, content_type) ⇒ Object
- .find_documents_by_query(arg_product_ids = nil, arg_content_type_ids = nil, arg_audience_ids = nil, finra = nil) ⇒ Object
- .find_documents_by_sami_code(sami_codes) ⇒ Object
- .fund_code_from_asset_path(path) ⇒ Object
- .fund_code_from_id(taxonomy_id) ⇒ Object
- .term_id_from_fund_code(code) ⇒ Object
Class Method Details
.find_documents_by_fund_code(fund_codes) ⇒ Object
3 4 5 6 |
# File 'app/service/digital_asset_lookup_service.rb', line 3 def self.find_documents_by_fund_code(fund_codes) ids = fund_codes.collect {|c| term_id_from_fund_code(c)} DigitalAsset.unscoped.content_type_in(DigitalAsset::ContentType::FUND_DOC_TYPES).product_in ids end |
.find_documents_by_fund_code_and_content_type(fund_codes, content_type) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'app/service/digital_asset_lookup_service.rb', line 8 def self.find_documents_by_fund_code_and_content_type(fund_codes,content_type) assets = DigitalAssetLookupService.find_documents_by_fund_code(fund_codes) found_asset = nil assets.each {|da| da.documents.each {|doc| found_asset = da if doc.content_type == content_type } } found_asset end |
.find_documents_by_query(arg_product_ids = nil, arg_content_type_ids = nil, arg_audience_ids = nil, finra = nil) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/service/digital_asset_lookup_service.rb', line 32 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 |
.find_documents_by_sami_code(sami_codes) ⇒ Object
53 54 55 |
# File 'app/service/digital_asset_lookup_service.rb', line 53 def self.find_documents_by_sami_code(sami_codes) DigitalAsset.sami_in sami_codes end |
.fund_code_from_asset_path(path) ⇒ Object
28 29 30 31 |
# File 'app/service/digital_asset_lookup_service.rb', line 28 def self.fund_code_from_asset_path(path) da = DigitalAsset.path_is(item.path).first fund_code = fund_for_digital_asset da end |
.fund_code_from_id(taxonomy_id) ⇒ Object
19 20 21 |
# File 'app/service/digital_asset_lookup_service.rb', line 19 def self.fund_code_from_id(taxonomy_id) TaxonomyTerm.term_id_is(taxonomy_id).try(:term_type).try([], 'FUND_CODE') end |
.term_id_from_fund_code(code) ⇒ Object
23 24 25 26 |
# File 'app/service/digital_asset_lookup_service.rb', line 23 def self.term_id_from_fund_code(code) term = TaxonomyTerm.fund_code_is(code) term.try(:first).try(:term_id) end |