Skip to content

Commit

Permalink
Merge pull request #159 from splaplapla/support-event-type-warn
Browse files Browse the repository at this point in the history
event-type warnを受け取れるようにする
  • Loading branch information
jiikko authored Jan 7, 2023
2 parents 94dae22 + 84753ad commit de85ca6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/models/event.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
class Event < ApplicationRecord
serialize :body, JSON

enum event_type: { boot: 0, reload_config: 10, load_config: 20, heartbeat: 30, error: 40, start_reboot: 50, }
enum event_type: { boot: 0, reload_config: 10, load_config: 20, heartbeat: 30, error: 40, warn: 45, start_reboot: 50, }

belongs_to :pbm_session

def self.event_types
[ OpenStruct.new(name: :error),
OpenStruct.new(name: :warn),
OpenStruct.new(name: :boot),
OpenStruct.new(name: :load_config),
OpenStruct.new(name: :reload_config),
Expand Down
2 changes: 2 additions & 0 deletions app/services/api/save_event_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def self.execute!(session_id: , hostname: , event_type: , body: , device_id: )
end
when "error"
next pbm_session.events.create!(event_type: :error, body: body)
when "warn"
next pbm_session.events.create!(event_type: :warn, body: body)
end
end
end
Expand Down

0 comments on commit de85ca6

Please sign in to comment.