refs DEV-2418 for more details.
I noticed when archiving a week, then in https://github.com/matomo-org/matomo/blob/4.7.1/core/Archive.php#L629-L643 we archive up to 2 days into the future. That means if today is
2022-02-09, then when archiving this week we also archive
2022-02-11. I noticed this in the archive tables:
In above screenshots we can see that the archive was created eg on 2nd Feb for a date in the future.
That means we create archives for in the future and of course these archives will have 0 data.
I assume that these archives in the future are also created for regular archives, not only dependent archives. However, I believe it works for these regular archives because they are invalidated again regularly and therefore the data is re-archived one or two days later. The logic for invalidating archives currently doesn't know which dependent archives exist with what segments. Meaning I'm assuming these get never invalidated.
I'm meaning calls like https://github.com/matomo-org/matomo/blob/4.7.1/plugins/Goals/Archiver.php#L124-L127
$this->getProcessor()->processDependentArchive('Goals', VisitFrequencyAPI::NEW_VISITOR_SEGMENT);. These calls also happen in non-core plugins specifically MediaAnalytics for example.
The goals of this issue is when invalidating any period (including any older period), then the dependent archives are also invalidated. Meaning if invalidating eg the "All Visits" segment, then it should also invalidate archives from dependent archives where it uses segments like
media_spent_time>0 and therefore archives for the flag of
donec276dccc46ea23c1bffdd046127f41d6.% needs to be invalidated too.
Maybe we need to have some event in something like https://github.com/matomo-org/matomo/blob/4.7.1/core/DataAccess/Model.php#L119 to also trigger archives for segments that are used by