Sha256: d474cebd8ccc946bd696f46a5d4e4adee768cbc960e37faba2b6da40dae68e2f
Contents?: true
Size: 1.2 KB
Versions: 19
Compression:
Stored size: 1.2 KB
Contents
module Spotlight ## # a log entry representing an attempt to reindex some number of records in an exhibit class ReindexingLogEntry < ActiveRecord::Base enum job_status: { unstarted: 0, in_progress: 1, succeeded: 2, failed: 3 } belongs_to :exhibit, class_name: 'Spotlight::Exhibit' belongs_to :user, class_name: '::User', optional: true # null start times sort to the top, to more easily surface pending reindexing default_scope { order('start_time IS NOT NULL, start_time DESC') } scope :recent, -> { limit(5) } scope :started_or_completed, -> { where.not(job_status: 'unstarted') } def duration end_time - start_time if end_time end def in_progress! self.start_time = Time.zone.now super rescue Rails.logger.error "unexpected error updating log entry to :in_progress from #{caller}" end def succeeded! self.end_time = Time.zone.now super rescue Rails.logger.error "unexpected error updating log entry to :succeeded from #{caller}" end def failed! self.end_time = Time.zone.now super rescue Rails.logger.error "unexpected error updating log entry to :failed from #{caller}" end end end
Version data entries
19 entries across 19 versions & 1 rubygems