-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
MatomoAnalyticsWiki: support for getting most visited pages #125
Conversation
@coderabbitai review |
Actions PerformedReview triggered.
|
WalkthroughThe recent updates enhance the Matomo analytics integration by introducing a new method to retrieve the most visited pages and refining the data retrieval process. These changes include adding a Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 3
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- includes/MatomoAnalyticsViewer.php (1 hunks)
- includes/MatomoAnalyticsWiki.php (4 hunks)
Additional comments not posted (2)
includes/MatomoAnalyticsWiki.php (2)
15-20
: Ensure the new parameters ingetData
are well-documented.
30-33
: The API request now correctly includes the new parameters.
@@ -27,6 +27,7 @@ public function getFormDescriptor( | |||
'visitpages' => $mA->getVisitPages(), | |||
'visitduration' => $mA->getVisitDurations(), | |||
'visitpass' => $mA->getVisitDaysPassed(), | |||
'mostvisited' => $mA->getMostVisistedPages(), |
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.
Typo in method name getMostVisistedPages()
.
- 'mostvisited' => $mA->getMostVisistedPages(),
+ 'mostvisited' => $mA->getMostVisitedPages(),
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
'mostvisited' => $mA->getMostVisistedPages(), | |
'mostvisited' => $mA->getMostVisitedPages(), |
@@ -39,7 +42,7 @@ private function getData( | |||
$arrayOut = []; | |||
|
|||
foreach ( $siteJson as $key => $val ) { | |||
if ( $flat ) { | |||
if ( $flatArray ) { |
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.
Consider handling null values more gracefully in the conditional.
- $arrayOut[$key] = $val ?: '-';
+ $arrayOut[$key] = isset( $val ) ? $val : '-';
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
if ( $flatArray ) { | |
if ( $flatArray ) { | |
$arrayOut[$key] = isset( $val ) ? $val : '-'; |
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.
Please make sure there is a space inside the parentheses so isset( $val )
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.
@Universal-Omega, thank you for pointing that out. I've adjusted the code snippet to include a space inside the parentheses as you requested:
$arrayOut[$key] = isset( $val ) ? $val : '-';
Please let me know if there's anything else you need!
public function getMostVisistedPages() { | ||
// We can also add support for linking to them through URLs with Actions.getPageUrls if we want | ||
return $this->getData( 'Actions.getPageTitles', 'today', 'month', 'label', 'nb_visits', 1 ); | ||
} |
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.
Typo in method name and consider making 'date' and 'period' parameters configurable.
- public function getMostVisistedPages() {
+ public function getMostVisitedPages() {
- return $this->getData( 'Actions.getPageTitles', 'today', 'month', 'label', 'nb_visits', 1 );
+ return $this->getData( 'Actions.getPageTitles', $date, $period, 'label', 'nb_visits', 1 );
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
public function getMostVisistedPages() { | |
// We can also add support for linking to them through URLs with Actions.getPageUrls if we want | |
return $this->getData( 'Actions.getPageTitles', 'today', 'month', 'label', 'nb_visits', 1 ); | |
} | |
public function getMostVisitedPages( string $date, string $period ) { | |
// We can also add support for linking to them through URLs with Actions.getPageUrls if we want | |
return $this->getData( 'Actions.getPageTitles', $date, $period, 'label', 'nb_visits', 1 ); | |
} |
Summary by CodeRabbit
New Features
Improvements
getData
method to include an optional date parameter and adjusted parameter types for better flexibility and functionality.