Skip to content

Commit 668d223

Browse files
committed
Optimization for Injector, getNextTasks
1 parent 1093583 commit 668d223

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

src/Model/Repository/Mysql/RecurringRepository.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,17 @@ public function __construct(\PDO $db)
1919

2020
public function getNextTasks()
2121
{
22-
$query = 'SELECT * FROM ' . Consts::RECURRING_TASKS_TABLE_NAME . ' WHERE status = :status_recu
23-
AND recu_id NOT IN (SELECT DISTINCT tasks.recu_id FROM tasks WHERE status = :status)';
22+
$query = sprintf(
23+
'SELECT * FROM %s
24+
WHERE status=%d
25+
AND recu_id NOT IN (SELECT DISTINCT recu_id FROM %s WHERE status=%d AND recu_id > 0)',
26+
Consts::RECURRING_TASKS_TABLE_NAME,
27+
Consts::RECURRING_TASK_STATUS_ACTIVE,
28+
Consts::TASKS_TABLE_NAME,
29+
Consts::STATUS_PENDING
30+
);
2431

25-
$stmt = $this->pdo->prepare($query);
26-
$stmt->bindValue(':status_recu', \G4\Tasker\Consts::RECURRING_TASK_STATUS_ACTIVE, \PDO::PARAM_INT);
27-
$stmt->bindValue(':status', \G4\Tasker\Consts::STATUS_PENDING, \PDO::PARAM_INT);
28-
$stmt->execute();
32+
$stmt = $this->pdo->query($query);
2933

3034
return array_map(function($data) {
3135
return \G4\Tasker\Model\Domain\Recurring::fromData($data);

0 commit comments

Comments
 (0)