Class: Consyncful::Sync
- Inherits:
-
Object
- Object
- Consyncful::Sync
- Includes:
- Mongoid::Document
- Defined in:
- lib/consyncful/sync.rb
Constant Summary collapse
- DEFAULT_LOCALE =
'en-NZ'
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.fresh ⇒ Object
20 21 22 23 |
# File 'lib/consyncful/sync.rb', line 20 def self.fresh destroy_all latest end |
.latest ⇒ Object
16 17 18 |
# File 'lib/consyncful/sync.rb', line 16 def self.latest last || new end |
Instance Method Details
#drop_stale ⇒ Object
25 26 27 28 29 |
# File 'lib/consyncful/sync.rb', line 25 def drop_stale stale = Base.where(:sync_id.ne => id, :sync_id.exists => true) puts Rainbow("Dropping #{stale.count} records that haven't been touched in this sync").red stale.destroy end |
#run ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/consyncful/sync.rb', line 31 def run stats = Consyncful::Stats.new load_all_models sync = start_sync sync_items(sync, stats) drop_stale self.next_url = sync.next_sync_url self.last_run_at = Time.current save stats.print_stats end |