bridge_cache 0.0.13 → 0.0.14

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2cf35b6ed21d06645abf57b3916c1667a3ed1662
4
- data.tar.gz: f1a621ee489a4fd84237bfa751aafdebcf781b51
3
+ metadata.gz: ec85e8d9190a1f04068b83e61e8ff1f89c62f73f
4
+ data.tar.gz: 08d8ed00a2b7780051359995510b6ab4ea9b37cb
5
5
  SHA512:
6
- metadata.gz: d5bfa0a4b29b09be6e5023cb0480fc83dd36b2b0040d545da1ed066f1edd1684db2d3970f59a10d259a7e809afa56e99b3669fe62c15f386c060f34a4a13bf7b
7
- data.tar.gz: e5f36d12d1b1764744c97236f756b141565f2f04ea836827a1eb7f235446b6b01e72e3b864f53ff981bbb2ff1e52e3cad45f362168d736b931000a15c8589e4d
6
+ metadata.gz: 32e16bac569d101fb386d8590961564bc79dc62b130795cfa35f5fee6165aed4df01b29eeec2abab16b63a95235263714a58c75ddc5e60c74c8e193c08a614b0
7
+ data.tar.gz: 8ef8c95858d5957766f53731e2b887dc2cd7badce0232ef26533e12369c1ac7c3b0ee8d72a2a53b8036ad22e27801a1ec4a543a99be7141304db35f22c561cfb
@@ -7,5 +7,10 @@ module BridgeCache::Data
7
7
  def create_from_csv_row(row)
8
8
  BridgeCache::Plugins::CSVDump::dump_row(self, row)
9
9
  end
10
+
11
+ def cleanup(row_ids)
12
+ # Implement this method in your model if you want to do any sort of post creation cleanup.
13
+ # See tagging.rb for an example.
14
+ end
10
15
  end
11
16
  end
@@ -0,0 +1,7 @@
1
+ module BridgeCache::Jobs
2
+ class CleanupJob < ActiveJob::Base
3
+ def perform(model, row_ids)
4
+ "BridgeCache::#{model.camelcase}".constantize.cleanup(row_ids)
5
+ end
6
+ end
7
+ end
@@ -10,9 +10,14 @@ module BridgeCache::Jobs
10
10
  remote_data.store_file(path)
11
11
  import = BridgeBlueprint::DataDump.new(path)
12
12
  models.each do |model|
13
+ row_ids = []
14
+
13
15
  import.each_row(model.pluralize) do |row|
14
16
  BridgeCache::Jobs::ImportRow.set(queue: self.queue_name).perform_later(model, row.to_h)
17
+ row_ids << row['id'].to_i
15
18
  end
19
+
20
+ BridgeCache::Jobs::CleanupJob.set(queue: self.queue_name).perform_later(model, row_ids)
16
21
  end
17
22
  end
18
23
 
@@ -5,5 +5,8 @@ module BridgeCache
5
5
  belongs_to :tag, foreign_key: :tag_id, primary_key: :bridge_id, class_name: 'BridgeCache::Tag', optional: true
6
6
  belongs_to :user, foreign_key: :tagger_id, primary_key: :bridge_id, class_name: 'BridgeCache::User', optional: true
7
7
 
8
+ def self.cleanup(current_row_ids)
9
+ BridgeCache::Tagging.where.not(bridge_id: current_row_ids).destroy_all
10
+ end
8
11
  end
9
12
  end
@@ -1,3 +1,3 @@
1
1
  module BridgeCache
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.14"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridge_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - jshaffer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-27 00:00:00.000000000 Z
11
+ date: 2017-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -179,6 +179,7 @@ files:
179
179
  - app/controllers/bridge_cache/application_controller.rb
180
180
  - app/helpers/bridge_cache/application_helper.rb
181
181
  - app/lib/bridge_cache/data/bridge_model.rb
182
+ - app/lib/bridge_cache/jobs/cleanup_job.rb
182
183
  - app/lib/bridge_cache/jobs/import_check.rb
183
184
  - app/lib/bridge_cache/jobs/import_data.rb
184
185
  - app/lib/bridge_cache/jobs/import_row.rb