Sha256: 15fa2a47f5fac22a06faff62c410b9b854a459c9c75ed4e3a8abfbefcbf52471
Contents?: true
Size: 787 Bytes
Versions: 2
Compression:
Stored size: 787 Bytes
Contents
# frozen_string_literal: true module Motor class Query < ::Motor::ApplicationRecord audited belongs_to :author, polymorphic: true, optional: true has_many :taggable_tags, as: :taggable, dependent: :destroy has_many :tags, through: :taggable_tags, class_name: 'Motor::Tag' has_many :alerts, dependent: :destroy attribute :preferences, default: -> { ActiveSupport::HashWithIndifferentAccess.new } serialize :preferences, HashSerializer scope :active, -> { where(deleted_at: nil) } def result(variables_hash = {}) result = Motor::Queries::RunQuery.call!(self, variables_hash: variables_hash) column_names = result.columns.pluck(:name) result.data.map { |row| column_names.zip(row).to_h } end alias run result end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
motor-admin-0.4.5 | app/models/motor/query.rb |
motor-admin-0.4.4 | app/models/motor/query.rb |