Enqueuer: update enqueue waiting time checks

🔥 Problem

The Enqueuer can enforce a waiting time between 2 migrations.

To do this, it will do the following:

  1. Gather all migrations in final states (import_done, pre_import_done, import_aborted).
  2. Take the most recent X_done_at timestamps and use that as the last activity.
  3. Use the delay between Time.zone.now and the timestamp in (2.).

The problem is that due to bugs, the related timestamps could be missing. If this statement is evaluated with a nil value, it will always return false = the job will be never allowed to run.

🚒 Solution

I think we should update the logic around the waiting time enforcement with:

  • Additionally consider import_skipped with the related timestamp migration_skipped_at
  • Make sure that all before_transition for each considered state that set the related timestamp uses any as the starting state.
    • Example of one that need an update
  • Add a guard similar to this one.
    • To avoid evaluating a nil last_import_step_done_at.
Edited by David Fernandez