Instead of having all the join strings hard coded this will do it in a more generic way. It may fix some bugs, possibly not. However, it does make things easier when changing/defining queries in Archivers as it more or less only worked so far, because some queries were written in a certain way.
This won't be a public API so the API itself is not as important.
Ping @mattab can you have a look?
Well done @tsteur - this refactoring was very complex to figure it out, and it will help in the future plugins to provide their own new custom
log_ tables, and make such tables available to segmentation. Some deep technical debt has just been removed :+1: