Class: GoogleReserveFeedFragment

Inherits:
ApplicationRecord show all
Extended by:
Enumerize
Defined in:
app/models/google_reserve_feed_fragment.rb

Overview

Schema Information

Table name: google_reserve_feed_fragments

id                :bigint           not null, primary key
failure_reason    :text(65535)
processing_status :string(20)       default("pending"), not null
upload_file_path  :string(500)
created_at        :datetime         not null
updated_at        :datetime         not null
restaurant_id     :integer          not null

Indexes

idx_google_reserve_feed_fragments_upload_file_path  (upload_file_path)
idx_grff_created_at                                 (created_at)
idx_grff_restaurant_unique                          (restaurant_id) UNIQUE
idx_grff_status                                     (processing_status)
idx_grff_status_created                             (processing_status,created_at)

Instance Method Summary collapse

Methods inherited from ApplicationRecord

sync_carrierwave_url

Instance Method Details

#mark_completed!(upload_file_path) ⇒ Boolean

Marks the fragment as completed with cloud storage file path

Parameters:

  • upload_file_path (String)

    Path to the uploaded gzip file in cloud storage (S3/DigitalOcean)

Returns:

  • (Boolean)

    True if successfully updated



34
35
36
37
38
39
40
# File 'app/models/google_reserve_feed_fragment.rb', line 34

def mark_completed!(upload_file_path)
  update!(
    processing_status: :completed,
    upload_file_path: upload_file_path,
    failure_reason: nil,
  )
end

#mark_failed!(error_message) ⇒ Object



42
43
44
45
46
47
48
# File 'app/models/google_reserve_feed_fragment.rb', line 42

def mark_failed!(error_message)
  update!(
    processing_status: :failed,
    failure_reason: error_message&.truncate(65535),
    upload_file_path: nil,
  )
end

#mark_upload_completed!Boolean

Marks the uploading status as completed

Returns:

  • (Boolean)

    True if successfully updated



52
53
54
# File 'app/models/google_reserve_feed_fragment.rb', line 52

def mark_upload_completed!
  update!(uploading_status: :completed)
end

#mark_upload_failed!(error_message) ⇒ Boolean

Marks the uploading status as failed

Parameters:

  • error_message (String)

    The error message

Returns:

  • (Boolean)

    True if successfully updated



59
60
61
62
63
64
# File 'app/models/google_reserve_feed_fragment.rb', line 59

def mark_upload_failed!(error_message)
  update!(
    uploading_status: :failed,
    failure_reason: error_message&.truncate(65535),
  )
end