Class: TelegramBotEngine::Event
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- TelegramBotEngine::Event
- Defined in:
- app/models/telegram_bot_engine/event.rb
Class Method Summary collapse
- .log(event_type:, action:, chat_id: nil, username: nil, details: {}) ⇒ Object
- .purge_old! ⇒ Object
- .purge_old_randomly! ⇒ Object
Class Method Details
.log(event_type:, action:, chat_id: nil, username: nil, details: {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/telegram_bot_engine/event.rb', line 16 def self.log(event_type:, action:, chat_id: nil, username: nil, details: {}) return unless TelegramBotEngine.config.event_logging return unless table_exists? create!( event_type: event_type, action: action, chat_id: chat_id, username: username, details: details ) purge_old_randomly! end |
.purge_old! ⇒ Object
31 32 33 |
# File 'app/models/telegram_bot_engine/event.rb', line 31 def self.purge_old! where("created_at < ?", TelegramBotEngine.config.event_retention_days.days.ago).delete_all end |
.purge_old_randomly! ⇒ Object
35 36 37 |
# File 'app/models/telegram_bot_engine/event.rb', line 35 def self.purge_old_randomly! purge_old! if rand(100).zero? end |