It's a very minor improvement in terms of performance or memory but figured this is executed every time we fetch a report so may be better to directly fetch the right result and be easier to debug. While debugging some archiving memory issues noticed this query returns often 3000 results (depends on the number of segments etc... can be more or less). It's mostly saving PHP time and less time in "sending data"
I can kind of get the tests to work but I'm quite certain there is a bug in the current archive selection. Might need to do some call some day to understand things why the current implementation is.
I'm not 100% sure but I think I can see that we falsely assume a site might have an invalidated archive when there is not (since we partially except any done flag)... leading potentially to unneeded archive invalidations maybe...
And we partially use possibly maybe the wrong visits/visits converted values in circumstances although this one might be fine.
Maybe I come back to this at some point but might just close it as it's hard to really understand how it is supposed to work and not to work