[VSA] Efficient iteration within the Group hierarchy

What

We need an efficient way to iterate over group-level data (issues, merge_requests) so we can populate and update the new VSA tables efficiently.

Example:

Issue.where(project_id: Group.last.all_projects.select(:id)).order(:updated_at, :id).find_each do |record|
  # ...
end

The query above is too slow and it will likely time out for large groups. The research MR implements efficient group-level queries.

How

Clean up, test the linked research MR and make it available in the codebase.

High-level API example:

Issue.within_hierarchy(Group.find(9979).self_and_descendants).order(:updated_at, :id)
Edited by Adam Hegyi