New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid any archiving queries in Goals Archiver if no goals or ecommerce are active #18354
Conversation
03368c4
to
54bef43
Compare
31ed8cf
to
fde393d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sgiehl I suppose it won't cause any issue if we don't implement similar logic in aggregate archives? I had this done initially in https://github.com/matomo-org/matomo/compare/improvegoalarchive?expand=1 but maybe it keeps code simpler if we don't do it like it did. Just not entirely sure if there could be downsides like if you request certain days and it doesn't find that archive, whether it would maybe try to archive it. But I think it won't as long as there is a done flag there. Just double checking.
The biggest benefit of this issue is to not having to go into $this->getProcessor()->processDependentArchive
when there is no goals and archive. I think that's currently still the case. Could we ideally not call it when there are no goals and no ecommerce?
This saves us having to create a temporary table for the new_visit and returning visit segment and not having to fetch these visitors (which can be very slow)
@tsteur won't |
@sgiehl AFAIK it would still try to resolve the segment because every time we process dependent archives it's also trying to resolve the number of visits we had for that segment even before we go into the goals archiver |
The only way would be to initialise a new archive manually for that segment and writing empty entries and finishing the archive without even going in there |
Haven't yet debugged that through, but won't those "VisitsSummary" numbers be archived by the |
It's something general the archiver does for any kind of archive. Even if it was a say customreports specific archive. I'm not sure if we can check for any other archives there as they may be outdated or be invalidated soon after this or something. Also would partially depend on the order in which plugins archive in the same archive etc. |
@tsteur added some code to skip the dependent archives if there are no goals and ecommerce isn't used. I guess that's the simplest solution for now even though that might mean that those archives might be archived later when that changes. |
@sgiehl we might need to do the same for the |
@tsteur Haven't tested that. But as there won't be a done flag for that segment, I'm pretty sure the day periods would then be processed. Just pushed an update so it will be skipped as well |
@@ -181,28 +177,12 @@ public function test_pluginOnlyArchivingDoesNotRelaunchChildArchives_whenReusing | |||
], | |||
[ | |||
'idarchive' => '3', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes to this files are caused by the fact, that the dependent archives are no longer been processed when no goals are available and ecommerce is disabled. Therefor the Goals
archives (for segments) disappeared. The VisitsSummary
archives are still present, as they are archived by the VisitFrequency
archiver.
71cb056
to
bb97183
Compare
@tsteur I tried working further on that. But actually I did not yet find a solution that would really work. Lines 472 to 500 in d5997bd
The getMetrics API tries to fetch the numeric record for nb_visits , which is a VisitsSummary metric...
The only useful solution I still would see is to process the dependent archives for goals in all cases (like it was in the beginning). The day archiver inserts empty archives and skips all queries. That for sure will also cause the core metrics being processed (which
|
3847e3c
to
5ad92ab
Compare
@tsteur I tried that, but it led to strange behavior when the VisitFrequency plugin was disabled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. We wouldn't want to create any such archive record for the VisitsSummary plugin either as we would be writing 0 entries probably when there could be visits etc.
Left only one comment to look at. Not sure we need to do anything there. Then good to merge 👍
plugins/Goals/Archiver.php
Outdated
|
||
/* | ||
* Archive General Goal metrics | ||
*/ | ||
$goalIdsToSum = GoalManager::getGoalIds($this->getProcessor()->getParams()->getSite()->getId()); | ||
|
||
//Ecommerce | ||
$goalIdsToSum[] = GoalManager::IDGOAL_ORDER; | ||
$goalIdsToSum[] = GoalManager::IDGOAL_CART; //bug here if idgoal=1 | ||
$goalIdsToSum = array_merge($goalIdsToSum, $this->getEcommerceIdGoals()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we only add the ecommerceGoalIds if ecommerce is enabled? and then $this->getProcessor()->aggregateNumericMetrics($fieldsToSum);
we could run only if $fieldsToSum
is not empty? $this->getProcessor()->aggregateNumericMetrics($fieldsToSum);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a check for ecommerce plugin. But the $goalIdsToSum
array actually always contains the entry false
, for processing the overview. Not sure if we should skip that one if no other goal is processed or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guess we could always keep the false
👍
This issue is in "needs review" but there has been no activity for 7 days. ping @matomo-org/core-reviewers |
This issue is in "needs review" but there has been no activity for 7 days. ping @matomo-org/core-reviewers |
@tsteur I've updated the tests. From my side everything should be done. Let me know if we can merge or if anything else needs to be adjusted. |
sounds good to merge @sgiehl 👍 |
Description:
fixes #18283
Note: The test changes are kind of expected. We had a couple of fixtures where ecommerce data was tracked, even though it actually wasn't enabled for that site.
For some Fixtures I have activate the ecommerce flag, while for others I kept it off on purpose. That way we can see that there are null records archived, even though some data would actually be tracked and available.
Review