Bg process feedback - list all processes ( ref. #130 )
This commit is contained in:
parent
5ac5146461
commit
1c022ff81e
|
@ -5,7 +5,9 @@ use Tainacan;
|
||||||
class Background_Importer_Heartbeat {
|
class Background_Importer_Heartbeat {
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
add_filter( 'heartbeat_received', array( &$this, 'bg_process_feedback' ), 10, 2 );
|
global $wpdb;
|
||||||
|
$this->table = $wpdb->prefix . 'tnc_bg_process';
|
||||||
|
add_filter( 'heartbeat_no_priv_received', array( &$this, 'bg_process_feedback' ), 10, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,9 +19,17 @@ class Background_Importer_Heartbeat {
|
||||||
* @param array $data Data received from the front end (unslashed).
|
* @param array $data Data received from the front end (unslashed).
|
||||||
*/
|
*/
|
||||||
public function bg_process_feedback( $response, $data ){
|
public function bg_process_feedback( $response, $data ){
|
||||||
$response['bg_process_feedback'] = true;
|
global $wpdb;
|
||||||
|
|
||||||
//TODO: list all bg process
|
$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";
|
||||||
|
|
||||||
|
$query = "SELECT * $base_query";
|
||||||
|
$result = $wpdb->get_results($query);
|
||||||
|
|
||||||
|
$response['bg_process_feedback'] = $result;
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue