From 59e716e9a231ef97d86384f00ed00d15db56dfa6 Mon Sep 17 00:00:00 2001 From: Abdullah Almsaeed Date: Mon, 1 Apr 2019 08:26:46 -0400 Subject: [PATCH] Auto correct queues table if there are items when there shouldn't be any --- includes/Elasticsearch/ESQueue.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/includes/Elasticsearch/ESQueue.php b/includes/Elasticsearch/ESQueue.php index bb65ef83..83d4acee 100644 --- a/includes/Elasticsearch/ESQueue.php +++ b/includes/Elasticsearch/ESQueue.php @@ -57,7 +57,7 @@ public static function progress() { $should_check = (int) db_query("SELECT COUNT(*) FROM queue WHERE name LIKE :es", [ - ':es' => db_like('elasticsearch').'%', + ':es' => db_like('elasticsearch') . '%', ])->fetchField(); $queues = []; @@ -73,6 +73,9 @@ public static function progress() { ORDER BY index_name ASC, priority ASC'; $queues = db_query($query)->fetchAll(); } + elseif (intval(db_query('SELECT COUNT(*) FROM {' . self::QUEUE_TABLE . '} WHERE completed < total')->fetchField())) { + db_query('UPDATE {' . self::QUEUE_TABLE . '} SET completed = total')->fetchAll(); + } $progress = []; $total = 0;