2020-08-27 09:19:55 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2020-08-27 10:29:57 +10:00
|
|
|
class DataExplorer::QuerySerializer < ActiveModel::Serializer
|
2022-12-29 12:31:29 +00:00
|
|
|
attributes :id,
|
|
|
|
|
:sql,
|
|
|
|
|
:name,
|
|
|
|
|
:description,
|
|
|
|
|
:param_info,
|
|
|
|
|
:created_at,
|
|
|
|
|
:username,
|
|
|
|
|
:group_ids,
|
|
|
|
|
:last_run_at,
|
|
|
|
|
:hidden,
|
|
|
|
|
:user_id
|
2020-08-27 10:29:57 +10:00
|
|
|
|
|
|
|
|
def param_info
|
|
|
|
|
object&.params&.map(&:to_hash)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def username
|
|
|
|
|
object&.user&.username
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def group_ids
|
|
|
|
|
object.groups.map(&:id)
|
|
|
|
|
end
|
|
|
|
|
end
|