Sha256: 338e1bfee63b29b17ac7420735d97a82b85972b6e16fb9538f88e1576d316b44
Contents?: true
Size: 1.13 KB
Versions: 57
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true module Bulkrax class Status < ApplicationRecord belongs_to :statusable, polymorphic: true belongs_to :runnable, polymorphic: true serialize :error_backtrace, Array scope :for_importers, -> { where(statusable_type: 'Bulkrax::Importer') } scope :for_exporters, -> { where(statusable_type: 'Bulkrax::Exporter') } scope :latest_by_statusable, -> { joins(latest_by_statusable_subtable.join_sources) } def self.latest_by_statusable_subtable status_table = self.arel_table latest_status_query = status_table.project(status_table[:statusable_id], status_table[:statusable_type], status_table[:id].maximum.as("latest_status_id")).group(status_table[:statusable_id], status_table[:statusable_type]) latest_status_table = Arel::Table.new(latest_status_query).alias(:latest_status) status_table.join(latest_status_query.as(latest_status_table.name.to_s), Arel::Nodes::InnerJoin) .on(status_table[:id].eq(latest_status_table[:latest_status_id])) end end end
Version data entries
57 entries across 57 versions & 1 rubygems