Fix jobs query in SQLite
This commit is contained in:
parent
d1afa44a2e
commit
15047b7288
|
@ -3224,11 +3224,15 @@ func (db *datastore) DeleteJobByPost(postID string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *datastore) GetJobsToRun(action string) ([]*PostJob, error) {
|
func (db *datastore) GetJobsToRun(action string) ([]*PostJob, error) {
|
||||||
|
timeWhere := "created < DATE_SUB(NOW(), INTERVAL delay MINUTE) AND created > DATE_SUB(NOW(), INTERVAL delay + 5 MINUTE)"
|
||||||
|
if db.driverName == driverSQLite {
|
||||||
|
timeWhere = "created < DATETIME('now', '-' || delay || ' MINUTE') AND created > DATETIME('now', '-' || (delay+5) || ' MINUTE')"
|
||||||
|
}
|
||||||
rows, err := db.Query(`SELECT pj.id, post_id, action, delay
|
rows, err := db.Query(`SELECT pj.id, post_id, action, delay
|
||||||
FROM publishjobs pj
|
FROM publishjobs pj
|
||||||
INNER JOIN posts p
|
INNER JOIN posts p
|
||||||
ON post_id = p.id
|
ON post_id = p.id
|
||||||
WHERE action = ? AND created < DATE_SUB(NOW(), INTERVAL delay MINUTE) AND created > DATE_SUB(NOW(), INTERVAL delay + 5 MINUTE)
|
WHERE action = ? AND `+timeWhere+`
|
||||||
ORDER BY created ASC`, action)
|
ORDER BY created ASC`, action)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Failed selecting from publishjobs: %v", err)
|
log.Error("Failed selecting from publishjobs: %v", err)
|
||||||
|
|
Loading…
Reference in New Issue