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

Testing a change to TB #22359

Closed
wants to merge 1 commit into from
Closed

Testing a change to TB #22359

wants to merge 1 commit into from

Conversation

ErisDS
Copy link
Member

@ErisDS ErisDS commented Mar 4, 2025

Got some code for us? Awesome 🎊!

Please include a description of your change & check your PR against this list, thanks!

  • There's a clear use-case for this code change, explained below
  • Commit message has a short title & references relevant issues
  • The build will pass (run yarn test:all and yarn lint)

We appreciate your contribution!

Copy link
Contributor

coderabbitai bot commented Mar 4, 2025

Walkthrough

The pull request primarily updates multiple files within the ghost/tinybird-dedicated directory by incrementing version numbers from 1 to 2. A new field, post_type (of type String), is added to the schema of the pages datasource, and the engine sorting key is updated accordingly. Several SQL queries in various pipes are modified to include the post_type field in the SELECT and GROUP BY clauses or as a filtering condition. In addition, some files have minor formatting changes, such as the removal of unnecessary blank lines and subtle updates to descriptive text regarding parameters. No changes were made to the underlying SQL logic or control flow beyond these updates and additions.


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: 0

🧹 Nitpick comments (1)
ghost/tinybird-dedicated/pipes/_hits.pipe (1)

19-19: Consider adding data validation for post_type.

While the toString() function safely handles null values, consider adding validation or default values for post_type if it's expected to have specific values. This would improve data quality and prevent issues downstream.

-        toString(payload.post_type) as post_type,
+        coalesce(toString(payload.post_type), 'unknown') as post_type,

Also applies to: 38-38

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 49b6a64 and 1de5b2a.

📒 Files selected for processing (23)
  • ghost/tinybird-dedicated/datasources/_pages_mv.datasource (2 hunks)
  • ghost/tinybird-dedicated/datasources/_sessions_mv.datasource (1 hunks)
  • ghost/tinybird-dedicated/datasources/_sources_mv.datasource (1 hunks)
  • ghost/tinybird-dedicated/pipes/_hits.pipe (3 hunks)
  • ghost/tinybird-dedicated/pipes/_kpis.pipe (1 hunks)
  • ghost/tinybird-dedicated/pipes/_pages.pipe (3 hunks)
  • ghost/tinybird-dedicated/pipes/_sessions.pipe (1 hunks)
  • ghost/tinybird-dedicated/pipes/_sources.pipe (1 hunks)
  • ghost/tinybird-dedicated/pipes/_top_browsers.pipe (1 hunks)
  • ghost/tinybird-dedicated/pipes/_top_devices.pipe (1 hunks)
  • ghost/tinybird-dedicated/pipes/_top_locations.pipe (1 hunks)
  • ghost/tinybird-dedicated/pipes/_top_pages.pipe (2 hunks)
  • ghost/tinybird-dedicated/pipes/_top_sources.pipe (1 hunks)
  • ghost/tinybird-dedicated/pipes/analytics_pages.pipe (1 hunks)
  • ghost/tinybird-dedicated/pipes/analytics_sessions.pipe (1 hunks)
  • ghost/tinybird-dedicated/pipes/chris_test.pipe (1 hunks)
  • ghost/tinybird-dedicated/pipes/top_browsers.pipe (1 hunks)
  • ghost/tinybird-dedicated/pipes/top_devices.pipe (1 hunks)
  • ghost/tinybird-dedicated/pipes/top_locations.pipe (1 hunks)
  • ghost/tinybird-dedicated/pipes/top_os.pipe (1 hunks)
  • ghost/tinybird-dedicated/pipes/top_pages.pipe (1 hunks)
  • ghost/tinybird-dedicated/pipes/top_pages_copy.pipe (1 hunks)
  • ghost/tinybird-dedicated/pipes/top_sources.pipe (1 hunks)
✅ Files skipped from review due to trivial changes (18)
  • ghost/tinybird-dedicated/pipes/_top_browsers.pipe
  • ghost/tinybird-dedicated/pipes/_sources.pipe
  • ghost/tinybird-dedicated/pipes/top_pages_copy.pipe
  • ghost/tinybird-dedicated/pipes/top_pages.pipe
  • ghost/tinybird-dedicated/datasources/_sources_mv.datasource
  • ghost/tinybird-dedicated/pipes/_sessions.pipe
  • ghost/tinybird-dedicated/pipes/analytics_pages.pipe
  • ghost/tinybird-dedicated/pipes/_top_devices.pipe
  • ghost/tinybird-dedicated/pipes/top_browsers.pipe
  • ghost/tinybird-dedicated/pipes/top_locations.pipe
  • ghost/tinybird-dedicated/pipes/chris_test.pipe
  • ghost/tinybird-dedicated/pipes/_top_sources.pipe
  • ghost/tinybird-dedicated/pipes/_kpis.pipe
  • ghost/tinybird-dedicated/pipes/top_os.pipe
  • ghost/tinybird-dedicated/pipes/_top_locations.pipe
  • ghost/tinybird-dedicated/pipes/analytics_sessions.pipe
  • ghost/tinybird-dedicated/pipes/top_devices.pipe
  • ghost/tinybird-dedicated/datasources/_sessions_mv.datasource
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: Ghost-CLI tests
  • GitHub Check: Database tests (Node 20.11.1, sqlite3)
  • GitHub Check: Regression tests (Node 20.11.1, sqlite3)
  • GitHub Check: Database tests (Node 22.13.1, mysql8)
  • GitHub Check: Tinybird Tests
  • GitHub Check: Regression tests (Node 20.11.1, mysql8)
  • GitHub Check: Database tests (Node 20.11.1, mysql8)
  • GitHub Check: Database tests (Node 18.12.1, mysql8)
  • GitHub Check: Unit tests (Node 22.13.1)
  • GitHub Check: Unit tests (Node 20.11.1)
  • GitHub Check: Unit tests (Node 18.12.1)
  • GitHub Check: i18n
  • GitHub Check: Lint
🔇 Additional comments (15)
ghost/tinybird-dedicated/pipes/top_sources.pipe (2)

1-1: Version number incremented appropriately.

The version has been updated from 1 to 2, which aligns with the schema changes across the system.


5-5: Documentation improvement for existing functionality.

The description now correctly mentions the skip and limit parameters used for pagination in line 45, which improves API documentation for users.

ghost/tinybird-dedicated/pipes/_top_pages.pipe (2)

1-1: Version number incremented appropriately.

The version increment from 1 to 2 is consistent with other file changes in this PR.


26-26: Filter for new post_type field implemented correctly.

The new conditional filter for post_type follows the same pattern as other filters in the query, maintaining consistency in the codebase.

ghost/tinybird-dedicated/pipes/_pages.pipe (3)

1-1: Version number incremented appropriately.

Version has been updated from 1 to 2, consistent with schema changes.


14-14: New field added to SELECT clause.

The post_type field has been added to the SELECT clause, which is necessary to expose this field in the query results.


27-28: GROUP BY clause updated correctly.

The GROUP BY clause has been updated to include both post_uuid and the new post_type field. Note that line 27 shows post_uuid has been moved from its previous position to accommodate the addition of post_type.

ghost/tinybird-dedicated/datasources/_pages_mv.datasource (4)

1-1: Version number incremented appropriately.

The version has been updated from 1 to 2, consistent with the schema changes.


7-7: New schema field added.

The post_type field of type String has been added to the schema, which enables tracking and filtering by post type.


19-19: Engine sorting key updated to include new field.

The ENGINE_SORTING_KEY has been properly updated to include the new post_type field, which is necessary for optimal query performance when filtering or grouping by this field.


1-20:

❓ Verification inconclusive

Verify that existing data migration is handled.

While the schema changes look good, it's important to ensure there's a plan for handling existing data that doesn't have the post_type field populated. This might involve a data migration strategy or handling null/default values.


🏁 Script executed:

#!/bin/bash
# Check if there are any other files in the PR that might handle data migration
echo "Checking for migration-related files in this PR..."
git diff --name-only HEAD~1 | grep -i migrat

# Check if there's any documentation about handling this schema change
echo "Checking for documentation on schema changes..."
git diff --name-only HEAD~1 | grep -i readme
git diff --name-only HEAD~1 | grep -i doc

Length of output: 914


ACTION REQUIRED: Confirm Data Migration for post_type Field

The schema update adds the post_type field, but we haven’t detected any accompanying migration scripts or documentation to handle pre-existing data. Please verify that there’s a clear strategy for addressing records that lack this field—whether through a backfill migration, default value, or another approach—to ensure data integrity.

  • Confirm that a migration plan is in place to populate post_type for already existing records.
  • Update documentation or include migration files as necessary.
ghost/tinybird-dedicated/pipes/_hits.pipe (4)

1-1: Version increment is properly applied.

The pipe version has been correctly incremented from 1 to 2, reflecting the addition of the new post_type field to the schema.


19-19: New post_type field properly added to parsed_hits query.

The post_type field is correctly extracted from the payload using toString(), following the same pattern as other payload fields in this query. This ensures consistent handling of potentially null values by converting them to strings.


38-38: New post_type field correctly included in analytics_hits_data.

The post_type field is properly passed through from the parsed_hits node to the analytics_hits_data node, ensuring the data flows correctly through the pipeline.


1-66:

❓ Verification inconclusive

Verify data consumers are updated for this schema change.

The addition of the post_type field and version increment indicates a schema change. Ensure that any downstream consumers of this pipe's data (dashboards, API integrations, etc.) are updated to handle the new field appropriately.


🏁 Script executed:

#!/bin/bash
# Search for files that might be consuming data from this pipe
echo "Searching for potential consumers of _hits.pipe..."
rg -g "!node_modules" -g "!.git" "_hits.pipe|analytics_hits_data" --type=all

# Check for any imports or references to analytics_hits_data
echo "Searching for references to analytics_hits_data..."
rg -g "!node_modules" -g "!.git" "analytics_hits_data" --type=all

# Look for any API endpoints that might be using this data
echo "Searching for potential API endpoints using this data..."
rg -g "!node_modules" -g "!.git" -g "*.js" "hits|analytics.*hits" --type=js

Length of output: 1486


Schema Change Verification: Ensure Downstream Consumers Handle the New post_type Field

The recent grep results reveal that there are multiple references to the analytics endpoints (e.g., in test files like ghost/admin/tests/acceptance/staff-test.js, ghost/admin/tests/acceptance/editor-test.js, ghost/api-framework/lib/Frame.js, and others). Although these references indicate that various parts of the application consume data from the updated pipe, it's not immediately clear if those consumers have been updated to accommodate the new post_type field.

Action Items:

  • Review Test Cases and API Endpoints: Confirm that all tests and API endpoints handling analytics_hits_data now account for the new post_type field.
  • Double-check Downstream Integrations: Verify that dashboards, integrations, or any external systems consuming this data have been updated for the schema change.

@ErisDS
Copy link
Member Author

ErisDS commented Mar 5, 2025

This was an experiment / demo that I don't need anymore

@ErisDS ErisDS closed this Mar 5, 2025
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