Module: QC::Later::Queries

Extended by:
Queries
Included in:
Queries
Defined in:
lib/queue_classic/later.rb

Instance Method Summary collapse

Instance Method Details

#delete_and_capture(not_before) ⇒ Object



37
38
39
40
41
# File 'lib/queue_classic/later.rb', line 37

def delete_and_capture(not_before)
  s = "DELETE FROM #{QC::Later::TABLE_NAME} WHERE not_before <= $1 RETURNING *"
  # need to ensure we return an Array even if Conn.execute returns a single item
  [QC::Conn.execute(s, not_before)].compact.flatten
end

#insert(q_name, not_before, method, args) ⇒ Object



30
31
32
33
34
35
# File 'lib/queue_classic/later.rb', line 30

def insert(q_name, not_before, method, args)
  QC.log_yield(:action => "insert_later_job") do
    s = "INSERT INTO #{QC::Later::TABLE_NAME} (q_name, not_before, method, args) VALUES ($1, $2, $3, $4)"
    QC::Conn.execute(s, q_name, not_before, method, JSON.dump(args))
  end
end