daengine 0.6.10 → 0.6.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a7ec04edac11e46187d3dd6b978c9841ca73832
4
- data.tar.gz: 69f6f64db73d5729782c85214e93691f0a0c8709
3
+ metadata.gz: 4a2ff236a90f4e3e9fd22ca6586e641cd968e5f9
4
+ data.tar.gz: 36a66024ce2ac659e8cdcea149c9b855607969eb
5
5
  SHA512:
6
- metadata.gz: 1fea624f3a6f85860cf36c471486cb6bfd1884eedff6b38fbfba34b4603d0a92145560db2b1f07c270fcb8e64fc654014449b7659dfe009af43736b4f00d17ed
7
- data.tar.gz: 83ef062a84f8d35612ec03b4a09c079f98e29bd7f815cb1c8e7743b212b5b43be64a8db8ef65b4609f822ae022cf694993c743e072b187dc783158f38add2b56
6
+ metadata.gz: 9a2191f074c80c664e0f56dbf370015d6c1549c0900732ff8fea277374b99653673a527d87519b8a15aaca790f5428af6b6ff5ec9d4ee9576a6df81334f88cff
7
+ data.tar.gz: 6d58d4df8d1577e312a0c84dc135ae53d50292bcbbc084419fe25072ae82c04fcb695fd9d42f020fd80d602687875c4d407a0569a2a06b995db3baf1f72f157e
@@ -89,9 +89,13 @@ class ServiceDigitalAsset < ActiveRecord::Base
89
89
  {'digital_asset' => hash}
90
90
  end
91
91
 
92
- def default_blank_time(time_field)
92
+ def default_blank_time(time_field, default_time = 10.years.ago)
93
93
  time = send(time_field.to_sym)
94
- time.blank? ? 10.years.ago : time
94
+ time.blank? ? default_time : time
95
+ end
96
+
97
+ def changed_since(date)
98
+ !changed_at.blank? && changed_at.to_i >= date.to_i
95
99
  end
96
100
 
97
101
  def self.boolean_field?(field_name)
@@ -10,7 +10,7 @@ module Daengine
10
10
 
11
11
  time do
12
12
  assets = parse_file(file)
13
- assets = select_1_asset_per_id(assets)
13
+ assets = select_1_asset_per_id(assets, last_read)
14
14
  assets = add_file_attributes(assets, last_read) unless Daengine.config[:disable_file_check]
15
15
  assets = add_fund_codes(assets)
16
16
  summary = call_service(assets)
@@ -30,19 +30,21 @@ module Daengine
30
30
  end
31
31
 
32
32
  def self.parse_file(file)
33
- puts "----- Parsing the file -----"
33
+ puts "----- Parsing the file -----"
34
34
  document = Document.new
35
35
  Nokogiri::XML::SAX::Parser.new(document).parse(file)
36
36
  Daengine.log("Nokogiri Parser complete...", "info")
37
37
  document.assets
38
38
  end
39
39
 
40
- def self.select_1_asset_per_id(assets)
40
+ def self.select_1_asset_per_id(assets, last_read)
41
+ comparison_date = last_read.nil? ? 10.years.ago : last_read - 5.minutes
41
42
  results = {}
42
43
  assets.each do |key, values|
43
- puts "----- select_1 #{key} -----"
44
+ puts "----- select_1 #{key} -----"
44
45
  list = values.find_all { |v| v.effective? }
45
46
  asset = most_recent_non_expired(list)
47
+ asset = (asset.changed_since(comparison_date) ? asset : nil) unless asset.nil?
46
48
  asset.finra_path = finra_path(list) unless asset.nil?
47
49
  results[key] = asset unless asset.nil?
48
50
  end
@@ -53,7 +55,7 @@ puts "----- select_1 #{key} -----"
53
55
  results = {}
54
56
  assets.each do |key, asset|
55
57
  begin
56
- puts "----- add_file #{key} -----"
58
+ puts "----- add_file #{key} -----"
57
59
  file_name = asset_file_name(asset)
58
60
  asset.mark_for_deletion unless File.file?(file_name)
59
61
 
@@ -70,7 +72,7 @@ puts "----- add_file #{key} -----"
70
72
  def self.add_fund_codes(assets)
71
73
  results = {}
72
74
  assets.each do |key, asset|
73
- puts "----- add_fund_codes #{key} -----"
75
+ puts "----- add_fund_codes #{key} -----"
74
76
  fund_codes = []
75
77
  asset.product_ids.each do |product_id|
76
78
  fund_code = DigitalAssetLookupService.fund_code_from_id(product_id)
@@ -86,7 +88,7 @@ puts "----- add_fund_codes #{key} -----"
86
88
  results = {:errors => 0, :updated => 0, :deleted => 0}
87
89
  assets.each_value do |asset|
88
90
  begin
89
- puts "----- call_service #{asset.digital_asset_id} -----"
91
+ puts "----- call_service #{asset.digital_asset_id} -----"
90
92
  if asset.delete?
91
93
  path = "#{service_uri}/#{asset.digital_asset_id}"
92
94
  options = {:method => :delete, :headers => header}
@@ -1,3 +1,3 @@
1
1
  module Daengine
2
- VERSION = "0.6.10"
2
+ VERSION = "0.6.11"
3
3
  end
@@ -9200,3 +9200,103 @@ Completed 406 Not Acceptable in 2.0ms
9200
9200
  Processing by DigitalAssetsController#search as HTML
9201
9201
  Parameters: {"digital_asset_id"=>"blargh-blargh-blargh", "title"=>"Doc Title"}
9202
9202
  Completed 406 Not Acceptable in 1.0ms
9203
+ Started GET "/digital_assets" for 127.0.0.1 at 2014-02-12 11:20:27 -0700
9204
+ Processing by DigitalAssetsController#index as JSON
9205
+ Completed 200 OK in 6.0ms (Views: 4.0ms)
9206
+ Started GET "/digital_assets?digital_asset_id=id-foobar-permanent-1" for 127.0.0.1 at 2014-02-12 11:20:27 -0700
9207
+ Processing by DigitalAssetsController#index as JSON
9208
+ Parameters: {"digital_asset_id"=>"id-foobar-permanent-1"}
9209
+ Completed 200 OK in 31.0ms (Views: 29.0ms)
9210
+ Started GET "/digital_assets?fund=00200" for 127.0.0.1 at 2014-02-12 11:20:27 -0700
9211
+ Processing by DigitalAssetsController#index as JSON
9212
+ Parameters: {"fund"=>"00200"}
9213
+ Completed 200 OK in 27.0ms (Views: 25.0ms)
9214
+ Started GET "/digital_assets?digital_asset_id=id-foobar-permanent-4" for 127.0.0.1 at 2014-02-12 11:20:27 -0700
9215
+ Processing by DigitalAssetsController#index as JSON
9216
+ Parameters: {"digital_asset_id"=>"id-foobar-permanent-4"}
9217
+ Completed 200 OK in 27.0ms (Views: 21.0ms)
9218
+ Started GET "/digital_assets?path=%2Fsome%2Fother%2Fpath.pdf" for 127.0.0.1 at 2014-02-12 11:20:27 -0700
9219
+ Processing by DigitalAssetsController#index as JSON
9220
+ Parameters: {"path"=>"/some/other/path.pdf"}
9221
+ Completed 200 OK in 22.0ms (Views: 20.0ms)
9222
+ Started GET "/digital_assets?digital_asset_id=id-foobar-permanent-6" for 127.0.0.1 at 2014-02-12 11:20:27 -0700
9223
+ Processing by DigitalAssetsController#index as JSON
9224
+ Parameters: {"digital_asset_id"=>"id-foobar-permanent-6"}
9225
+ Completed 200 OK in 33.0ms (Views: 29.0ms)
9226
+ Started GET "/digital_assets?published=2014-02-12+16%3A20%3A27+UTC" for 127.0.0.1 at 2014-02-12 11:20:27 -0700
9227
+ Processing by DigitalAssetsController#index as JSON
9228
+ Parameters: {"published"=>"2014-02-12 16:20:27 UTC"}
9229
+ Completed 200 OK in 78.0ms (Views: 25.0ms)
9230
+ Started GET "/digital_assets/foo-bar-id" for 127.0.0.1 at 2014-02-12 11:20:27 -0700
9231
+ Processing by DigitalAssetsController#show as JSON
9232
+ Parameters: {"id"=>"foo-bar-id"}
9233
+ Completed 200 OK in 46.0ms (Views: 12.0ms)
9234
+ Started GET "/digital_assets/not-found-doc" for 127.0.0.1 at 2014-02-12 11:20:28 -0700
9235
+ Processing by DigitalAssetsController#show as JSON
9236
+ Parameters: {"id"=>"not-found-doc"}
9237
+ Completed 404 Not Found in 80.0ms (Views: 1.0ms)
9238
+ Started PUT "/digital_assets/foo-bar-digital-asset-id" for 127.0.0.1 at 2014-02-12 11:20:28 -0700
9239
+ Processing by DigitalAssetsController#update as JSON
9240
+ Parameters: {"digital_asset"=>{"audiences"=>["investor"], "omniture_codes"=>["KOW2MY24D"], "orderable"=>"false", "pages"=>"1", "fund_codes"=>["00200", "00190", "00210"], "_id"=>"foo-bar-digital-asset-id", "title"=>"another title", "changed_at"=>"2014-02-10 18:20:26 UTC", "digital_asset_id"=>"foo-bar-digital-asset-id", "published_at"=>"2014-02-02 18:20:26 UTC", "expires_at"=>"2014-04-12 18:20:26 UTC", "sami_code"=>"IL1111.077", "business_owner"=>"biz owner", "path"=>"/9/foo/bar.txt", "finra_path"=>"/path/finradoc/10/foo/bar.txt", "legacy_path"=>"/oldpath/10/foo/bar.txt", "doc_changed_at"=>"2014-02-10 18:20:26 UTC", "content_type"=>"fact_sheet", "updated_at"=>"2014-02-12 18:20:28 UTC", "created_at"=>"2014-02-12 18:20:28 UTC"}, "id"=>"foo-bar-digital-asset-id"}
9241
+ Completed 200 OK in 30.0ms
9242
+ Started POST "/digital_assets" for 127.0.0.1 at 2014-02-12 11:20:28 -0700
9243
+ Processing by DigitalAssetsController#create as JSON
9244
+ Parameters: {"digital_asset"=>{"audiences"=>["investor"], "omniture_codes"=>["KOW2MY24D"], "orderable"=>"false", "pages"=>"1", "fund_codes"=>["00200", "00190", "00210"], "_id"=>"52fbbb6cf2e6a4e84c4c68dd", "title"=>"Doc Title", "changed_at"=>"2014-02-10 18:20:26 UTC", "digital_asset_id"=>"new-digital-asset-id", "published_at"=>"2014-02-02 18:20:26 UTC", "expires_at"=>"2014-04-12 18:20:26 UTC", "sami_code"=>"IL1111.077", "business_owner"=>"biz owner", "path"=>"/10/foo/bar.txt", "finra_path"=>"/path/finradoc/11/foo/bar.txt", "legacy_path"=>"/oldpath/11/foo/bar.txt", "doc_changed_at"=>"2014-02-10 18:20:26 UTC", "content_type"=>"fact_sheet"}}
9245
+ Completed 201 Created in 80.0ms
9246
+ Started DELETE "/digital_assets/foo-bar-digital-asset-id" for 127.0.0.1 at 2014-02-12 11:20:28 -0700
9247
+ Processing by DigitalAssetsController#destroy as JSON
9248
+ Parameters: {"id"=>"foo-bar-digital-asset-id"}
9249
+ Completed 200 OK in 6.0ms
9250
+ Started POST "/digital_assets/updated_time" for 127.0.0.1 at 2014-02-12 11:20:28 -0700
9251
+ Processing by DigitalAssetsController#updated_time as JSON
9252
+ Parameters: {"ids"=>["id-1", "id-2", "id-3", "id-4"]}
9253
+ Completed 200 OK in 42.0ms (Views: 0.0ms)
9254
+ Processing by DigitalAssetsController#index as HTML
9255
+ Completed 200 OK in 4.0ms (Views: 2.0ms)
9256
+ Processing by DigitalAssetsController#show as HTML
9257
+ Parameters: {"id"=>"id-foobar-permanent-9"}
9258
+ Completed 406 Not Acceptable in 5.0ms
9259
+ Processing by DigitalAssetsController#show as HTML
9260
+ Parameters: {"id"=>"IL1111.077"}
9261
+ Completed 406 Not Acceptable in 9.0ms
9262
+ Processing by DigitalAssetsController#show as HTML
9263
+ Parameters: {"id"=>"IL1111.077"}
9264
+ Completed 406 Not Acceptable in 6.0ms
9265
+ Processing by DigitalAssetsController#show as HTML
9266
+ Parameters: {"id"=>"id-foobar-permanent-13"}
9267
+ Completed 406 Not Acceptable in 5.0ms
9268
+ Processing by DigitalAssetsController#search as HTML
9269
+ Completed 200 OK in 5.0ms (Views: 4.0ms)
9270
+ Processing by DigitalAssetsController#search as HTML
9271
+ Parameters: {"path"=>"/one/off.path"}
9272
+ Completed 200 OK in 18.0ms (Views: 16.0ms)
9273
+ Processing by DigitalAssetsController#search as HTML
9274
+ Parameters: {"doctype"=>"fact_sheet"}
9275
+ Completed 200 OK in 8.0ms (Views: 3.0ms)
9276
+ Processing by DigitalAssetsController#search as HTML
9277
+ Parameters: {"doctype"=>["fact_sheet", "prospectus"]}
9278
+ Completed 200 OK in 18.0ms (Views: 16.0ms)
9279
+ Processing by DigitalAssetsController#search as HTML
9280
+ Parameters: {"sami"=>"SOMETHING.001"}
9281
+ Completed 200 OK in 33.0ms (Views: 32.0ms)
9282
+ Processing by DigitalAssetsController#search as HTML
9283
+ Parameters: {"audience"=>"492"}
9284
+ Completed 200 OK in 37.0ms (Views: 35.0ms)
9285
+ Processing by DigitalAssetsController#search as HTML
9286
+ Parameters: {"title"=>"Doc Title"}
9287
+ Completed 200 OK in 6.0ms (Views: 3.0ms)
9288
+ Processing by DigitalAssetsController#search as HTML
9289
+ Parameters: {"digital_asset_id"=>"id-foobar-permanent-35"}
9290
+ Completed 200 OK in 19.0ms (Views: 18.0ms)
9291
+ Processing by DigitalAssetsController#search as HTML
9292
+ Parameters: {"business_owner"=>"biz owner"}
9293
+ Completed 200 OK in 4.0ms (Views: 2.0ms)
9294
+ Processing by DigitalAssetsController#search as HTML
9295
+ Parameters: {"digital_asset_id"=>"id-foobar-permanent-42", "title"=>"Doc Title"}
9296
+ Completed 200 OK in 13.0ms (Views: 11.0ms)
9297
+ Processing by DigitalAssetsController#search as HTML
9298
+ Parameters: {"title"=>"Doc Title", "audiences"=>["investor"], "sami"=>"IL1111.077"}
9299
+ Completed 200 OK in 93.0ms (Views: 90.0ms)
9300
+ Processing by DigitalAssetsController#search as HTML
9301
+ Parameters: {"digital_asset_id"=>"blargh-blargh-blargh", "title"=>"Doc Title"}
9302
+ Completed 200 OK in 4.0ms (Views: 2.0ms)
@@ -37,15 +37,16 @@ describe Daengine::TeamsiteMetadataProcessor do
37
37
  end
38
38
  end
39
39
 
40
- context '#filter_assets' do
40
+ context '#select_1_asset_per_id' do
41
41
  let(:asset) { FactoryGirl.build :service_digital_asset }
42
42
  let(:other_asset) { FactoryGirl.build :service_digital_asset }
43
+ let(:last_read) { 1.year.ago }
43
44
 
44
45
  it 'should return assets that are effective' do
45
46
  id = asset.digital_asset_id
46
47
  assets = {id => [asset]}
47
48
 
48
- results = subject.select_1_asset_per_id(assets)
49
+ results = subject.select_1_asset_per_id(assets, last_read)
49
50
 
50
51
  results[id].should == asset
51
52
  end
@@ -55,7 +56,7 @@ describe Daengine::TeamsiteMetadataProcessor do
55
56
  asset.expires_at = nil
56
57
  assets = {id => [asset]}
57
58
 
58
- results = subject.select_1_asset_per_id(assets)
59
+ results = subject.select_1_asset_per_id(assets, last_read)
59
60
 
60
61
  results[id].should be_nil
61
62
  end
@@ -65,7 +66,7 @@ describe Daengine::TeamsiteMetadataProcessor do
65
66
  asset.display_on_website = false
66
67
  assets = {id => [asset]}
67
68
 
68
- results = subject.select_1_asset_per_id(assets)
69
+ results = subject.select_1_asset_per_id(assets, last_read)
69
70
 
70
71
  results[id].should be_nil
71
72
  end
@@ -75,12 +76,12 @@ describe Daengine::TeamsiteMetadataProcessor do
75
76
  other_asset.expires_at = 1.day.ago
76
77
 
77
78
  assets = {id => [asset, other_asset]}
78
- results = subject.select_1_asset_per_id(assets)
79
+ results = subject.select_1_asset_per_id(assets, last_read)
79
80
  results[id].should == asset
80
81
 
81
82
  # order in list shouldn't matter
82
83
  assets = {id => [other_asset, asset]}
83
- results = subject.select_1_asset_per_id(assets)
84
+ results = subject.select_1_asset_per_id(assets, last_read)
84
85
  results[id].should == asset
85
86
  end
86
87
 
@@ -89,12 +90,12 @@ describe Daengine::TeamsiteMetadataProcessor do
89
90
  other_asset.path = '/foo/manifest' + other_asset.path
90
91
 
91
92
  assets = {id => [asset, other_asset]}
92
- results = subject.select_1_asset_per_id(assets)
93
+ results = subject.select_1_asset_per_id(assets, last_read)
93
94
  results[id].should == asset
94
95
 
95
96
  # order in list shouldn't matter
96
97
  assets = {id => [other_asset, asset]}
97
- results = subject.select_1_asset_per_id(assets)
98
+ results = subject.select_1_asset_per_id(assets, last_read)
98
99
  results[id].should == asset
99
100
  end
100
101
 
@@ -103,12 +104,12 @@ describe Daengine::TeamsiteMetadataProcessor do
103
104
  other_asset.content_type = DigitalAsset::ContentType::FINRA
104
105
 
105
106
  assets = {id => [asset, other_asset]}
106
- results = subject.select_1_asset_per_id(assets)
107
+ results = subject.select_1_asset_per_id(assets, last_read)
107
108
  results[id].should == asset
108
109
 
109
110
  # order in list shouldn't matter
110
111
  assets = {id => [other_asset, asset]}
111
- results = subject.select_1_asset_per_id(assets)
112
+ results = subject.select_1_asset_per_id(assets, last_read)
112
113
  results[id].should == asset
113
114
  end
114
115
 
@@ -118,11 +119,21 @@ describe Daengine::TeamsiteMetadataProcessor do
118
119
  finra_path = other_asset.path
119
120
 
120
121
  assets = {id => [asset, other_asset]}
121
- results = subject.select_1_asset_per_id(assets)
122
+ results = subject.select_1_asset_per_id(assets, last_read)
122
123
  result = results[id]
123
124
  result.should == asset
124
125
  result.finra_path.should == finra_path
125
126
  end
127
+
128
+ it 'should remove assets that have not changed since the last_read time' do
129
+ read_time = 1.day.ago
130
+ id = asset.digital_asset_id
131
+ assets = {id => [asset]}
132
+
133
+ results = subject.select_1_asset_per_id(assets, read_time)
134
+
135
+ results[id].should be_nil
136
+ end
126
137
  end
127
138
 
128
139
  context '#add_file_attributes' do
@@ -1 +1 @@
1
- last_read_time: 2014-02-07 08:20:30 -0700
1
+ last_read_time: 2014-02-12 11:20:31 -0700
@@ -1 +1 @@
1
- last_read_time: 2014-02-07 08:20:33 -0700
1
+ last_read_time: 2014-02-12 11:20:35 -0700
@@ -132,5 +132,17 @@ describe ServiceDigitalAsset do
132
132
 
133
133
  result.to_i.should == expected.to_i
134
134
  end
135
+
136
+ it 'returns true if the asset has been updated since the provided date' do
137
+ date = 7.days.ago
138
+
139
+ asset.changed_since(date).should == true
140
+ end
141
+
142
+ it 'returns false if the asset has not been updated since the provided date' do
143
+ date = Time.now
144
+
145
+ asset.changed_since(date).should == false
146
+ end
135
147
  end
136
148
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daengine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.10
4
+ version: 0.6.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - sbhatia
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-11 00:00:00.000000000 Z
12
+ date: 2014-02-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails