Class: HasHelpers::PendingDBOperation
- Inherits:
-
MasterRecord
- Object
- MasterRecord
- HasHelpers::PendingDBOperation
- Defined in:
- app/models/has_helpers/pending_db_operation.rb
Class Method Summary collapse
-
.defer_processing(id) ⇒ Object
This method clears the enqueued_at field, so the op will get picked up for processing later.
- .mark_op_as_queued(id) ⇒ Object
Instance Method Summary collapse
Class Method Details
.defer_processing(id) ⇒ Object
This method clears the enqueued_at field, so the op will get picked up for processing later. The Worker can use this if it decides not to process an Op. Without calling this, that op would never get processed; this lets the MasterWorker re-enqueue this op later.
19 20 21 |
# File 'app/models/has_helpers/pending_db_operation.rb', line 19 def self.defer_processing(id) where(id: id).update_all(enqueued_at: nil) end |
.mark_op_as_queued(id) ⇒ Object
10 11 12 |
# File 'app/models/has_helpers/pending_db_operation.rb', line 10 def self.mark_op_as_queued(id) where(id: id).update_all("enqueued_at = now() at time zone 'utc'") end |
Instance Method Details
#defer_processing ⇒ Object
23 24 25 |
# File 'app/models/has_helpers/pending_db_operation.rb', line 23 def defer_processing self.class.defer_processing(id) end |
#execute(connection: self.class.connection) ⇒ Object
27 28 29 |
# File 'app/models/has_helpers/pending_db_operation.rb', line 27 def execute(connection: self.class.connection) connection.execute("SELECT run_one_db_operation(#{id})") end |