demarches-normaliennes/app/dashboards/email_event_dashboard.rb

25 lines
821 B
Ruby
Raw Normal View History

require "administrate/base_dashboard"
class EmailEventDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::Number,
to: Field::String,
subject: Field::String,
method: Field::Enum,
status: Field::Enum,
processed_at: Field::DateTime.with_options(format: "%F %T")
}
COLLECTION_ATTRIBUTES = [:id, :to, :subject, :method, :status, :processed_at].freeze
SHOW_PAGE_ATTRIBUTES = [:id, :to, :subject, :method, :status, :processed_at].freeze
METHODS_FILTERS =
ActionMailer::Base.delivery_methods.keys.index_with do |method|
-> (resources) { resources.where(method: method) }
end
COLLECTION_FILTERS = {
dispatched: -> (resources) { resources.dispatched },
dispatch_error: -> (resources) { resources.dispatch_error }
}.merge(METHODS_FILTERS).freeze
end