How Poll Results Work and Why They May Be Delayed

How Poll Results Work and Why They May Be Delayed

How Poll Results Are GeneratedResults Calculation Cron JobCan I Accelerate The Hourly Cron Job?

How Poll Results Are Generated
Each time a poll form submission occurs, results are processed. Those processed results are then displayed to the user. The results are then cached until another submission triggers them to need to be rebuilt again.
In some rare cases, when there are thousands of submissions on a particular poll, the results may not be able to be generated quickly, and thus the results displayed may be behind the actual submissions.
Results Calculation Cron Job
If results take longer than five seconds to generate, a cron is created which will attempt to rebuild the results hourly. Once the cron is created, it will attempt every hour to complete the result generation.
Simply giving some time for the results to be generated will allow the data to once again become accurate.
Can I Accelerate The Hourly Cron Job?
Yes. With a bit of custom code, you can adjust the cron task to run more often. For example, a failure could attempt twice an hour rather than hourly. The snippet below will do that.
add_filter( 'gform_polls_cron_schedule', 'cron_add_twice_hourly' );
function cron_add_twice_hourly() {
// Adds once weekly to the existing schedules.
$schedule['twicehourly'] = array(
'interval' => 1800, // number of seconds in the interval
'display' => __( 'Twice Hourly' )
);
return $schedule;
}

Note: After inserting this snippet, you will need to deactivate and reactivate the Polls Add-On to reschedule an existing task.

發表回覆

您的電子郵箱地址不會被公開。 必填項已用 * 標註