Skip to content

Instantly share code, notes, and snippets.

@domchristie
Created July 6, 2025 15:39
Show Gist options
  • Select an option

  • Save domchristie/2cc514c86fe42fbde1b71862c93f1fe8 to your computer and use it in GitHub Desktop.

Select an option

Save domchristie/2cc514c86fe42fbde1b71862c93f1fe8 to your computer and use it in GitHub Desktop.
class Feed < ApplicationRecord
has_many :imports
has_one :latest_import, -> { order(started_at: :desc) }, class_name: "Import"
has_one :latest_successful_import, -> { where(error: nil).order(started_at: :desc) }, class_name: "Import"
end
class Import < ApplicationRecord
has_operation :operation
belongs_to :feed
def reprocess
new_import = self.class.new(feed:)
new_import.operation = operation.dup
new_import.operation.processed_at = nil
new_import.save
new_import.operation.process
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment