daengine 0.2.17 → 0.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +1 -1
- data/app/models/taxonomy_term.rb +1 -1
- data/app/service/digital_asset_lookup_service.rb +6 -14
- data/lib/daengine/version.rb +1 -1
- data/spec/dummy/log/development.log +8 -0
- data/spec/factories.rb +0 -1
- metadata +2 -3
- data/app/models/labeled_digital_asset.rb +0 -28
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
|
-----------------------
|
data/app/models/taxonomy_term.rb
CHANGED
@@ -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(
|
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(
|
4
|
-
|
5
|
-
|
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.
|
18
|
-
|
19
|
-
|
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
|
data/lib/daengine/version.rb
CHANGED
@@ -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]])
|
data/spec/factories.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: daengine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
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-
|
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
|