-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Redefine when revenue information is displayed on All Websites Dashboard #22886
Open
mneudert
wants to merge
6
commits into
5.x-dev
Choose a base branch
from
dev-15665
base: 5.x-dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+491
−737
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
74a435f
Hide revenue information on All Websites Dashboard more often
mneudert 800fdd6
Update MultiSites fixture with different revenue sources
mneudert 2089900
Add tests for MultiSites revenue column configurations
mneudert b2a8a67
Update expected test results
mneudert 15b4dc0
Fix Goals.getGoals API when requesting more than one site
mneudert c2c0ea2
Add changelog entry for Goals.getGoals changes
mneudert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,10 +82,17 @@ public function getGoal($idSite, $idGoal) | |
* @param string|array $idSite Array or Comma separated list of website IDs to request the goals for | ||
* @param bool $orderByName | ||
* | ||
* @return array Array of Goal attributes | ||
* @return array Array of Goal attributes, | ||
* indexed by "idgoal" when requesting a single site, | ||
* no specific index when requesting multiple sites | ||
*/ | ||
public function getGoals($idSite, bool $orderByName = false): array | ||
{ | ||
if (is_array($idSite)) { | ||
$idSite = array_map('intval', $idSite); | ||
$idSite = implode(',', $idSite); | ||
} | ||
|
||
$cacheId = self::getCacheId($idSite); | ||
$cache = $this->getGoalsInfoStaticCache(); | ||
if (!$cache->contains($cacheId)) { | ||
|
@@ -101,10 +108,15 @@ public function getGoals($idSite, bool $orderByName = false): array | |
Piwik::checkUserHasViewAccess($idSite); | ||
|
||
$goals = $this->getModel()->getActiveGoals($idSite); | ||
$cleanedGoals = []; | ||
$indexByIdGoal = 1 === count($idSite); | ||
|
||
$cleanedGoals = array(); | ||
foreach ($goals as &$goal) { | ||
$cleanedGoals[$goal['idgoal']] = $this->formatGoal($goal); | ||
if ($indexByIdGoal) { | ||
$cleanedGoals[$goal['idgoal']] = $this->formatGoal($goal); | ||
} else { | ||
$cleanedGoals[] = $this->formatGoal($goal); | ||
} | ||
Comment on lines
+112
to
+119
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't quite understand why you would want this different behavior if there is a single goal or multiple? What's the problem with always setting the array index as the ID goal? |
||
} | ||
|
||
$cache->save($cacheId, $cleanedGoals); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.