Sha256: 537a2eaba666c608e7c29d09cd05bde3c5e022a3e97f485cc50789f65b2d913d
Contents?: true
Size: 1.28 KB
Versions: 4
Compression:
Stored size: 1.28 KB
Contents
class Action < MLS::Model self.inheritance_column = nil attr_accessor :account_id belongs_to :event belongs_to :subject, :polymorphic => true has_many :mistakes has_many :metadata, foreign_key: :event_id, primary_key: :event_id def self.by_performer(filter) req = Net::HTTP::Get.new("/actions/by_performer") req.body = { where: filter }.to_json JSON.parse(connection.instance_variable_get(:@connection).send_request(req).body) end def self.squash(attributes) squashed_actions = [] where(nil).each do |action| action.account_id = action.metadata.where(key: 'performed_by_id').first&.value action.diff = action.diff.slice(*attributes) if attributes if squashed_actions.last && action.account_id == squashed_actions.last.account_id && action.timestamp + 15.minutes > squashed_actions.last.timestamp action.diff.each do |key, value| next if value[0] == value[1] # filter sometimes logs even if the same if squashed_actions.last.diff[key] squashed_actions.last.diff[key][0] = value[0] else squashed_actions.last.diff[key] = value end end else squashed_actions << action end end squashed_actions end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
mls-1.9.0 | lib/mls/models/action.rb |
mls-1.8.0 | lib/mls/models/action.rb |
mls-1.7.0 | lib/mls/models/action.rb |
mls-1.6.0 | lib/mls/models/action.rb |