Sha256: 85f3e51dc85cb8b80df43aaac197701aec0637cf88eb1996dd0f7a24012e5e2e

Contents?: true

Size: 660 Bytes

Versions: 75

Compression:

Stored size: 660 Bytes

Contents

module Pageflow
  # @api private
  module AutoSnapshotPruning
    extend self

    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

    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
  end
end

Version data entries

75 entries across 75 versions & 1 rubygems

Version Path
pageflow-17.0.4 app/models/pageflow/auto_snapshot_pruning.rb
pageflow-17.0.3 app/models/pageflow/auto_snapshot_pruning.rb
pageflow-17.0.2 app/models/pageflow/auto_snapshot_pruning.rb
pageflow-17.0.1 app/models/pageflow/auto_snapshot_pruning.rb
pageflow-17.0.0 app/models/pageflow/auto_snapshot_pruning.rb
pageflow-16.2.0 app/models/pageflow/auto_snapshot_pruning.rb
pageflow-16.1.0 app/models/pageflow/auto_snapshot_pruning.rb
pageflow-16.0.0 app/models/pageflow/auto_snapshot_pruning.rb
pageflow-15.8.0 app/models/pageflow/auto_snapshot_pruning.rb
pageflow-14.5.2 app/models/pageflow/auto_snapshot_pruning.rb
pageflow-15.7.1 app/models/pageflow/auto_snapshot_pruning.rb
pageflow-15.7.0 app/models/pageflow/auto_snapshot_pruning.rb
pageflow-15.6.1 app/models/pageflow/auto_snapshot_pruning.rb
pageflow-15.6.0 app/models/pageflow/auto_snapshot_pruning.rb
pageflow-15.5.0 app/models/pageflow/auto_snapshot_pruning.rb
pageflow-15.4.0 app/models/pageflow/auto_snapshot_pruning.rb
pageflow-15.3.0 app/models/pageflow/auto_snapshot_pruning.rb
pageflow-15.2.2 app/models/pageflow/auto_snapshot_pruning.rb
pageflow-15.2.1 app/models/pageflow/auto_snapshot_pruning.rb
pageflow-15.2.0 app/models/pageflow/auto_snapshot_pruning.rb