Sha256: db11ec8377d2bdccb761d90628b02a0ce7b0ae4f78dba885d7265cb1b8f37830
Contents?: true
Size: 1.04 KB
Versions: 11
Compression:
Stored size: 1.04 KB
Contents
module Messaging module Adapters class Postgres class Category # @return [String] the name of the category attr_reader :name # Should not be used directly. # Use {Messaging.category} or {Store#category} # @api private # @see Messaging.category # @see Store.category def initialize(name) @name = name end # Access to all messages in the category sorted by created_at # @return [ActiveRecord::Relation] def messages SerializedMessage.where(stream_category: name).order(:created_at) end def messages_older_than(time) messages.where('created_at < ?', time) end def delete_messages_older_than!(time) SerializedMessage.transaction do ActiveRecord::Base.connection.execute "SET LOCAL statement_timeout = '0'" messages_older_than(time).delete_all end end def inspect "#<Category:#{name}>>" end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems