Filter uncanny-automator

automator_api_log_view_query

Filters the database query used to retrieve automator API logs before they are displayed.

add_filter( 'automator_api_log_view_query', $callback, 10, 1 );

Description

Filters the SQL query string used to retrieve trigger log entries for the API view. Developers can modify this query to customize which log data is fetched, allowing for advanced filtering or data inclusion before it's returned.


Usage

add_filter( 'automator_api_log_view_query', 'your_function_name', 10, 1 );

Parameters

$qry (mixed)
This parameter contains the SQL query string used to retrieve data for the API log view, which can be modified by filters.

Return Value

The filtered value.


Examples

/**
 * Filter the query to include only logs for completed triggers.
 *
 * This function modifies the SQL query used to fetch trigger logs,
 * ensuring that only logs associated with successfully completed
 * triggers are returned.
 *
 * @param string $qry The original SQL query string.
 * @return string The modified SQL query string.
 */
add_filter( 'automator_api_log_view_query', function( $qry ) {
    global $wpdb;

    // Append a condition to filter for completed triggers.
    // Assuming there's a 'status' column in the trigger log table.
    $qry .= " AND tl.status = 'completed'";

    return $qry;
}, 10, 1 );

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

src/core/class-automator-db.php:642

ON pt.ID = tl.automator_trigger_id
				LEFT JOIN {$wpdb->prefix}uap_trigger_log_meta tsen
				ON tsen.automator_trigger_log_id = tl.ID AND tsen.meta_key = 'sentence_human_readable'
				LEFT JOIN {$wpdb->users} u
				ON tl.user_id = u.ID
				WHERE api.type = 'trigger'";

		return apply_filters(
			'automator_api_log_view_query',
			$qry
		);
	}

	/**
	 * Check if specific VIEW is missing.

Scroll to Top