Closed swissspidy closed 6 years ago
We could also unschedule the previous event if the was another change:
$next_schedule = wp_next_scheduled( 'traduttore.generate_zip', [ $translation->translation_set_id ] )
if ( $next_schedule ) {
wp_unschedule_event( 'traduttore.generate_zip', $next_schedule, [ $translation->translation_set_id ] ) );
}
wp_schedule_single_event( time() + MINUTE_IN_SECONDS * 5, 'traduttore.generate_zip', [ $translation->translation_set_id ] );
I thought about that too, but it won‘t directly solve the issue described in the screenshot, does it?
Another thought: enable people to set up a fixed cron event instead and disable these single events.
It depends, it would delay the build until there was no new translation 5 minutes after the last change. Based on the screenshot the builds seem to be nearly every 5 minutes so I think the solution would have reduced the builds.
Fwiw: translate.w.org uses 30 minutes.
Let‘s do this then and add some filters as well.
In the same swoop I can also improve docs for all the cron things.
In #3 the time we wait until the next ZIP file generation has been reduced to 5 minutes.
I get it that one doesn't want to wait 15 minutes all the time, but when lots of translations are happening, it gets noisy quickly:
Can we somehow prevent this by throttling notifications or changing the time again? For the latter I suggest making them filterable. Both for the incoming webhook event as well as the language pack generation.