daengine 0.2.17 → 0.2.18

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -5,7 +5,7 @@ daengine is a rails engine plugin gem that provides access to digital assets, ak
5
5
  SSC documents/pdfs such as fund documents from the rails applications. It also
6
6
  includes the parser code that reads digital-asset metadata produced by the
7
7
  Teamsite legacy CMS and ingests it into a MongoDB instance for use by the client
8
- API.
8
+ API..
9
9
 
10
10
  Installation
11
11
  -----------------------
@@ -19,7 +19,7 @@ class TaxonomyTerm
19
19
  scope :term_id_is, ->(term_id) { where(:term_id => term_id) }
20
20
  scope :parent_term_in, ->(parent_term_id) { where(:parent_term.in => parent_term_id)}
21
21
  scope :label_is, ->(label) {where(:label => label)}
22
- scope :fund_code_is, ->(fund_code) { where("term_type.FUND_CODE" => fund_code)}
22
+ scope :fund_code_is, ->(fund_code) { where(:'term_type.FUND_CODE' => fund_code.gsub(/^0*/, ""))}
23
23
 
24
24
  def self.purge!
25
25
  TaxonomyTerm.destroy_all
@@ -1,25 +1,17 @@
1
1
  class DigitalAssetLookupService
2
2
 
3
- def self.find_documents_by_fund_code(fund_code)
4
- da=[]
5
- taxonomy_term = TaxonomyTerm.send(:fund_code_is, fund_code)
6
- unless taxonomy_term.empty?
7
- p "Found product_id => #{taxonomy_term[0].term_id} for fund_code => #{fund_code} from Taxonomy."
8
- da = DigitalAsset.send(:product_in, [taxonomy_term[0].term_id])
9
- end
10
- da
3
+ def self.find_documents_by_fund_code(fund_codes)
4
+ ids = fund_codes.collect {|c| term_id_from_fund_code(c)}
5
+ DigitalAsset.product_in ids
11
6
  end
12
7
 
13
8
  def self.fund_code_from_id(taxonomy_id)
14
9
  TaxonomyTerm.term_id_is(taxonomy_id).try(:term_type).try([], 'FUND_CODE')
15
10
  end
16
11
 
17
- def self.fund_documents(fund_codes)
18
- # return a hash containing fund_code => [docs]
19
- fund_codes.reduce({}) do |sum, code|
20
- sum[code] = find_documents_by_fund_code(code)
21
- sum
22
- end
12
+ def self.term_id_from_fund_code(code)
13
+ term = TaxonomyTerm.fund_code_is(code)
14
+ term.try(:first).try(:term_id)
23
15
  end
24
16
 
25
17
  end
@@ -1,3 +1,3 @@
1
1
  module Daengine
2
- VERSION = "0.2.17"
2
+ VERSION = "0.2.18"
3
3
  end
@@ -9,3 +9,11 @@ MONGODB (37ms) admin['$cmd'].find({:ismaster=>1}).limit(-1)
9
9
  MONGODB (352ms) dummy_development['system.namespaces'].find({})
10
10
  MONGODB (76ms) dummy_development['$cmd'].find({:create=>"digital_assets"}).limit(-1)
11
11
  MONGODB (14ms) dummy_development['$cmd'].find({"count"=>"digital_assets", "query"=>{}, "fields"=>nil}).limit(-1)
12
+ MONGODB [DEBUG] Logging level is currently :debug which could negatively impact client-side performance. You should set your logging level no lower than :info in production.
13
+ MONGODB (71ms) admin['$cmd'].find({:ismaster=>1}).limit(-1)
14
+ MONGODB (284ms) dummy_development['system.namespaces'].find({})
15
+ MONGODB (51ms) dummy_development['$cmd'].find({:create=>"taxonomy_terms"}).limit(-1)
16
+ MONGODB (6ms) dummy_development['taxonomy_terms'].find({:"term_type.FUND_CODE"=>"foo"}).limit(-1).sort([[:_id, :asc]])
17
+ MONGODB (5ms) dummy_development['taxonomy_terms'].find({:"term_type.FUND_CODE"=>"735"}).limit(-1).sort([[:_id, :asc]])
18
+ MONGODB (13ms) dummy_development['$cmd'].find({"count"=>"taxonomy_terms", "query"=>{:term_type=>{"$exists"=>true}}, "fields"=>nil}).limit(-1)
19
+ MONGODB (5ms) dummy_development['taxonomy_terms'].find({}).limit(-1).sort([[:_id, :asc]])
@@ -13,7 +13,6 @@ FactoryGirl.define do
13
13
  sequence(:guid) {|n| "guid-foobar-permanent-#{n}"}
14
14
  published_at 10.days.ago
15
15
  expires_at 2.months.from_now
16
- fund_ids ['420']
17
16
  sami_code 'IL1111.077'
18
17
  product_ids ['690', '420']
19
18
  business_owner 'biz owner'
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: daengine
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.17
5
+ version: 0.2.18
6
6
  platform: ruby
7
7
  authors:
8
8
  - sbhatia
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-08-16 00:00:00.000000000Z
13
+ date: 2012-08-17 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -81,7 +81,6 @@ files:
81
81
  - app/helpers/digital_assets_helper.rb
82
82
  - app/models/content_service_resource.rb
83
83
  - app/models/digital_asset.rb
84
- - app/models/labeled_digital_asset.rb
85
84
  - app/models/taxonomy_term.rb
86
85
  - app/service/digital_asset_lookup_service.rb
87
86
  - app/views/digital_assets/index.html.erb
@@ -1,28 +0,0 @@
1
- class LabeledDigitalAsset < DelegateClass(DigitalAsset)
2
- def initialize(da)
3
- super(da)
4
- end
5
-
6
- def audiences
7
- auds = __getobj__.audiences
8
- auds.map do |a|
9
- term = TaxonomyTerm.term_id_is(a).try(:first)
10
- label = term.try(:label)
11
- term => label
12
- end
13
- end
14
-
15
- def fund
16
- prods = __getobj__.product_ids
17
- # for any product ids that have a FUND_CODE, return the first
18
- prods.each do |p|
19
- term = TaxonomyTerm.term_id_is(p).try(:first)
20
- tt = term.try(:term_type)
21
- if(tt.try(:[], 'FUND_CODE'))
22
- return tt['FUND_CODE'] => term.label
23
- end
24
- end
25
- return nil
26
- end
27
-
28
- end