Skip to content
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

Added graph to stats page for os #22291

Merged
merged 3 commits into from
Feb 26, 2025
Merged

Added graph to stats page for os #22291

merged 3 commits into from
Feb 26, 2025

Conversation

9larsons
Copy link
Contributor

ref https://linear.app/ghost/issue/ANAL-128/

  • added a chart for OS to the technical section on the stats page

Copy link
Contributor

coderabbitai bot commented Feb 26, 2025

Walkthrough

The pull request introduces an apiVersion property to the props of a ReactComponent in the TechnicalComponent class. The component’s logic now verifies if the selected option is 'os' and whether apiVersion is undefined or below 1; if so, it switches the selection to 'devices'. The switch statement for determining the data fetching endpoint has been updated to use this effective selection and now includes a specific case for 'os' that constructs the endpoint based on the apiVersion. In addition, the endpoints for 'browsers' and 'devices' are updated to directly use the apiVersion from props. A further change involves conditionally rendering a button for the operating systems tab in the technical overview template, based on the @apiVersion value. Minor adjustments in the technical overview script simplify getter return statements without altering logic. The StatsController class has also been modified to track the os parameter, and the stats.hbs template now passes the @os property to multiple components.

Possibly related PRs

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ghost/admin/app/controllers/stats.js

Oops! Something went wrong! :(

ESLint: 8.44.0

Error: Failed to load parser '@babel/eslint-parser' declared in 'ghost/admin/.eslintrc.js': Cannot find module '@babel/eslint-parser'
Require stack:

  • /ghost/admin/.eslintrc.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Function.resolve (node:internal/modules/helpers:145:19)
    at Object.resolve (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2346:46)
    at ConfigArrayFactory._loadParser (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3325:39)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3099:43)
    at _normalizeObjectConfigDataBody.next ()
    at ConfigArrayFactory._normalizeObjectConfigData (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3040:20)
    at _normalizeObjectConfigData.next ()
    at ConfigArrayFactory.loadInDirectory (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2886:28)
    at CascadingConfigArrayFactory._loadConfigInAncestors (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3871:46)
ghost/admin/app/components/stats/charts/technical.js

Oops! Something went wrong! :(

ESLint: 8.44.0

Error: Failed to load parser '@babel/eslint-parser' declared in 'ghost/admin/.eslintrc.js': Cannot find module '@babel/eslint-parser'
Require stack:

  • /ghost/admin/.eslintrc.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Function.resolve (node:internal/modules/helpers:145:19)
    at Object.resolve (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2346:46)
    at ConfigArrayFactory._loadParser (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3325:39)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3099:43)
    at _normalizeObjectConfigDataBody.next ()
    at ConfigArrayFactory._normalizeObjectConfigData (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3040:20)
    at _normalizeObjectConfigData.next ()
    at ConfigArrayFactory.loadInDirectory (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2886:28)
    at CascadingConfigArrayFactory._loadConfigInAncestors (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3871:46)
ghost/admin/app/utils/stats.js

Oops! Something went wrong! :(

ESLint: 8.44.0

Error: Failed to load parser '@babel/eslint-parser' declared in 'ghost/admin/.eslintrc.js': Cannot find module '@babel/eslint-parser'
Require stack:

  • /ghost/admin/.eslintrc.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Function.resolve (node:internal/modules/helpers:145:19)
    at Object.resolve (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2346:46)
    at ConfigArrayFactory._loadParser (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3325:39)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3099:43)
    at _normalizeObjectConfigDataBody.next ()
    at ConfigArrayFactory._normalizeObjectConfigData (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3040:20)
    at _normalizeObjectConfigData.next ()
    at ConfigArrayFactory.loadInDirectory (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2886:28)
    at CascadingConfigArrayFactory._loadConfigInAncestors (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3871:46)

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0ad33a9 and eb18f08.

📒 Files selected for processing (4)
  • ghost/admin/app/components/stats/charts/technical.js (2 hunks)
  • ghost/admin/app/controllers/stats.js (2 hunks)
  • ghost/admin/app/templates/stats.hbs (5 hunks)
  • ghost/admin/app/utils/stats.js (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • ghost/admin/app/components/stats/charts/technical.js
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Admin tests - Chrome
🔇 Additional comments (4)
ghost/admin/app/utils/stats.js (1)

148-148: LGTM - Well-integrated OS parameter handling

The addition of the os parameter to the destructured properties and the conditional block to include it in the params object follows the same pattern as other filters (device, browser, etc). This is a clean implementation that maintains consistency with the existing code structure.

Also applies to: 182-184

ghost/admin/app/controllers/stats.js (2)

11-11: LGTM - Proper controller setup for OS tracking

The addition of 'os' to the queryParams array and the new tracked property follow the same pattern as other filter parameters. This ensures the OS parameter is properly tracked and managed in the URL.

Also applies to: 18-18


78-78: LGTM - Consistent filter clearing

The update to the clearFilters action correctly resets the new os parameter to null, maintaining consistency with how other filter parameters are handled.

ghost/admin/app/templates/stats.hbs (1)

90-90: LGTM - Consistent parameter passing to components

The addition of the @os={{this.os}} property to all relevant components ensures that the operating system filter is properly passed to each component that needs it. This implementation correctly follows the pattern established for other filter parameters.

Also applies to: 105-105, 118-118, 134-134, 147-147

✨ Finishing Touches
  • 📝 Generate Docstrings

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a8fa52f and 0ad33a9.

📒 Files selected for processing (3)
  • ghost/admin/app/components/stats/charts/technical.js (2 hunks)
  • ghost/admin/app/components/stats/technical-overview.hbs (1 hunks)
  • ghost/admin/app/components/stats/technical-overview.js (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • ghost/admin/app/components/stats/technical-overview.js
🔇 Additional comments (3)
ghost/admin/app/components/stats/technical-overview.hbs (1)

14-19: Well implemented conditional OS tab rendering

The conditional rendering of the OS tab button based on API version is cleanly implemented. This ensures the button only appears when the API supports OS data (apiVersion > 0), providing a smooth experience for users regardless of their API version.

ghost/admin/app/components/stats/charts/technical.js (2)

30-38: Good fallback implementation for unsupported API versions

The fallback logic for handling OS selection when the API version doesn't support it is well-designed. By creating an effectiveSelected variable, the code gracefully falls back to 'devices' when OS is selected but not supported by the current API version.


53-68: Well-structured endpoint configuration based on API version

The switch statement has been effectively updated to use effectiveSelected and dynamically construct endpoints based on the apiVersion. This is a clean approach that maintains backward compatibility while supporting the new OS statistics feature.

Comment on lines 33 to 35
console.log(`selected`, selected)
console.log(`apiVersion`, apiVersion)
let effectiveSelected = selected;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Remove debug console.log statements

There are several console.log statements that should be removed before merging to production.

-        console.log(`selected`, selected)
-        console.log(`apiVersion`, apiVersion)
         let effectiveSelected = selected;
         if (selected === 'os' && (!apiVersion || apiVersion < 1)) {
             effectiveSelected = 'devices';
         }
-        console.log(`effectiveSelected`, effectiveSelected)

Also applies to: 39-39

@9larsons 9larsons merged commit 41ccf1e into main Feb 26, 2025
20 checks passed
@9larsons 9larsons deleted the add-os-stats branch February 26, 2025 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant