runInsert :: ToJSON a =>
  Connection -> Text -> Text -> a -> UTCTime -> IO ()
runInsert con name method args at = do
  let q = "INSERT INTO scheduled_jobs (q_name, method, args, next_push_at) VALUES (?, ?, ?, ?)"
  _ <- execute con q (name, method, toJSON args, at')
  return ()
  where
  at' = C.posixSecondsToUTCTime $ toSeconds $ utcTimeToPOSIXSeconds at

----------------------------------------------------------------------
-- Job scheduling
----------------------------------------------------------------------

-- | Observe the database and move jobs from scheduled_jobs to
-- queue_classic_jobs.
runInsert :: ToJSON a =>
  Connection -> Text -> Text -> a -> UTCTime -> IO ()
runInsert con name method args at = do
  let q = "INSERT INTO scheduled_jobs (q_name, method, args, next_push_at) VALUES (?, ?, ?, ?)"
  _ <- execute con q (name, method, toJSON args, at')
  return ()
  where
  at' = C.posixSecondsToUTCTime $ toSeconds $ utcTimeToPOSIXSeconds at

----------------------------------------------------------------------
-- Job scheduling
----------------------------------------------------------------------

-- | Observe the database and move jobs from scheduled_jobs to
-- queue_classic_jobs.
runInsert con name method args at = do
  let q = "INSERT INTO scheduled_jobs (q_name, method, args, next_push_at) VALUES (?, ?, ?, ?)"
  _ <- execute con q (name, method, toJSON args, at')
  return ()
  where
  at' = C.posixSecondsToUTCTime $ toSeconds $ utcTimeToPOSIXSeconds at

----------------------------------------------------------------------
-- Job scheduling
----------------------------------------------------------------------

-- | Observe the database and move jobs from scheduled_jobs to
-- queue_classic_jobs.