refactor bg process heartbeat integration #130

This commit is contained in:
leogermani 2019-01-08 10:36:21 -02:00
parent f65a739a24
commit cbe9fdda49
2 changed files with 8 additions and 9 deletions

View File

@ -1,6 +1,5 @@
<?php
namespace Tainacan\Importer;
use Tainacan;
namespace Tainacan;
class Background_Importer_Heartbeat {
@ -11,7 +10,7 @@ class Background_Importer_Heartbeat {
}
/**
* Receive Heartbeat data and respond.
* Receive Heartbeat data and response.
*
* Processes data received via a Heartbeat request, and returns additional data to pass back to the front end.
*
@ -24,7 +23,7 @@ class Background_Importer_Heartbeat {
$user_q = $wpdb->prepare("AND user_id = %d", get_current_user_id());
$status_q = "";
$base_query = "FROM $this->table WHERE 1=1 $status_q $user_q ORDER BY priority DESC, queued_on DESC";
$base_query = "FROM $this->table WHERE processed_last >= NOW() - INTERVAL 10 MINUTE";
$query = "SELECT * $base_query";
$result = $wpdb->get_results($query);

View File

@ -162,8 +162,8 @@ $Tainacan_Gutenberg_Block = \Tainacan\GutenbergBlock::get_instance();
$Tainacan_Search_Engine = new \Tainacan\Search_Engine();
$Tainacan_Elastic_press = new \Tainacan\Elastic_Press();
require_once(__DIR__ . '/../importer/class-tainacan-bg-importer-heartbeat.php');
$Tainacan_Importer_Heartbeat = new \Tainacan\Importer\Background_Importer_Heartbeat();
require_once(__DIR__ . '/class-tainacan-background-process-heartbeat.php');
$Tainacan_Importer_Heartbeat = new \Tainacan\Background_Importer_Heartbeat();
$Tainacan_Capabilities = \Tainacan\Capabilities::get_instance();