Moving rebuild queue out of QueueWorker in order to provide flexibility for use cases where we don't want to generate the whole queue.
This takes the changes from comment #5 without including all the batch processing (moved to a separate merge request).
Closes #3180776