Trigger a downstream aggregation job when the nightly rollup completes
Kick a downstream aggregation job — an Analytics Dashboard add-on reaggregate, a custom BI export, or an external analytics warehouse push — immediately after the nightly feed-request-log rollup completes. benecaster_feed_request_rollup_completed fires once per rollup date with the date string and the number of aggregate rows written.
This avoids polling the benecaster_feed_request_daily table on a timer: your consumer wakes exactly when fresh data is available. The rows_written field guards against unnecessary work when a rollup pass touches nothing.
Code
<?php
add_action( 'benecaster_feed_request_rollup_completed', function ( array $ctx ): void {
// Only re-aggregate when the primary rollup actually wrote rows.
if ( 0 === $ctx['rows_written'] ) {
return;
}
// Schedule the downstream job on the immediate action queue so we
// don't block the cron pass.
wp_schedule_single_event(
time() + 60,
'my_addon_reaggregate_dashboard_metrics',
[ $ctx['date'] ]
);
} );