Module: Pageflow::AutoSnapshotPruning Private

Extended by:
AutoSnapshotPruning
Included in:
AutoSnapshotPruning
Defined in:
app/models/pageflow/auto_snapshot_pruning.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#dirty_entry_ids(options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



6
7
8
9
10
11
12
13
14
# File 'app/models/pageflow/auto_snapshot_pruning.rb', line 6

def dirty_entry_ids(options)
  Revision
    .auto_snapshots
    .where('created_at < ?', options.fetch(:created_before))
    .select('COUNT(*) as revisions_count, entry_id')
    .group('entry_id')
    .having('revisions_count > ?', options.fetch(:keep_count))
    .map(&:entry_id)
end

#prune(entry, options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
19
20
21
22
23
24
# File 'app/models/pageflow/auto_snapshot_pruning.rb', line 16

def prune(entry, options)
  entry
    .revisions
    .auto_snapshots
    .where('created_at < ?', options[:created_before])
    .order('created_at DESC')
    .offset(options[:keep_count])
    .each(&:destroy)
end