FarmBot/Farmbot-Web-App

View on GitHub
app/mutations/alerts/create.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Alerts
  class Create < Mutations::Command
    required do
      model :device
      string :problem_tag, in: Alert::PROBLEM_TAGS
    end

    optional do
      string :slug # Default is `SecureRandom.uuid`
      integer :priority, default: 99
    end

    def execute
      Alert.create!({ slug: slug || SecureRandom.uuid }.merge(inputs))
    end
  end
end