wearerequired / traduttore

🗼 A WordPress plugin to improve the I18N workflow for your own projects based on @GlotPress.
https://wearerequired.github.io/traduttore/
72 stars 12 forks source link

Make cron event times filterable #66

Closed swissspidy closed 6 years ago

swissspidy commented 6 years ago

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:

screenshot 2018-10-24 at 10 34 51

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.

ocean90 commented 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 ] );
swissspidy commented 6 years ago

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.

ocean90 commented 6 years ago

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.

swissspidy commented 6 years ago

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.