Skip to content

fix(docs): Remove AI instructions to multiply percentage metrics by 100#10607

Draft
keydunov wants to merge 1 commit intomasterfrom
cursor/CUB-2081-ai-percentage-multiplier-removal-d8b3
Draft

fix(docs): Remove AI instructions to multiply percentage metrics by 100#10607
keydunov wants to merge 1 commit intomasterfrom
cursor/CUB-2081-ai-percentage-multiplier-removal-d8b3

Conversation

@keydunov
Copy link
Copy Markdown
Member

@keydunov keydunov commented Apr 1, 2026

Description

This PR removes incorrect AI instructions and examples that suggest multiplying percentage metrics by 100. The Cube frontend now automatically handles percentage formatting when format: percent is specified, so multiplication by 100 in the SQL is no longer needed and results in incorrect values (e.g., showing 5000% instead of 50%).

Changes

Documentation Updates

  • Getting Started Guides: Updated completed_percentage examples in Cloud and Databricks tutorials
  • Data Modeling Overview: Updated generated SQL example for paying_percentage
  • Recipes: Updated percentage calculations in:
    • Event Analytics (bounce rate, repeat rate)
    • Cohort Retention (retention percentage)
    • Using Dynamic Measures (order status percentages)
    • Calculated Members (purchase percentage)
  • API Documentation: Updated SQL API query format examples

Code Changes

  • Funnels Extension: Updated conversionsPercent measure to use 1.0 * instead of 100.0 *
  • Example Schemas:
    • examples/recipes/active-users: Fixed WAU to MAU ratio
    • examples/recipes/referencing-dynamic-measures: Fixed percentage measures
  • Test Fixtures: Updated calendar_orders.yml test fixture

Key Changes

Before (Incorrect):

- name: completed_percentage
  type: number
  sql: "(100.0 * {CUBE.completed_count} / NULLIF({CUBE.count}, 0))"
  format: percent

After (Correct):

- name: completed_percentage
  type: number
  sql: "(1.0 * {CUBE.completed_count} / NULLIF({CUBE.count}, 0))"
  format: percent

Rationale

  • The frontend automatically multiplies by 100 when displaying values with format: percent
  • Multiplying by 100 in SQL causes double multiplication (100 * 100 = 10,000x)
  • Keeping 1.0 * ensures proper floating-point division while avoiding the multiplication issue
  • This aligns with the existing Databricks tutorial which already uses the correct pattern

Testing

  • Verified all documentation examples are consistent
  • Updated test fixtures to match new pattern
  • Confirmed Funnels extension generates correct SQL

Related Issue

Resolves CUB-2081

Linear Issue: CUB-2081

Open in Web Open in Cursor 

- Updated documentation to use 1.0 * instead of 100.0 * for percentage calculations
- Frontend now automatically multiplies by 100 when format: percent is used
- Changed examples in getting started guides, recipes, and API documentation
- Updated Funnels extension conversionsPercent measure
- Updated test fixtures and example schemas
- Kept decimal point multiplication (1.0 *) to ensure proper floating point division

Resolves CUB-2081

Co-authored-by: Artyom Keydunov <artyom.keydunov@gmail.com>
@github-actions github-actions bot added the javascript Pull requests that update Javascript code label Apr 1, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.91%. Comparing base (c773953) to head (493b641).
⚠️ Report is 1 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (c773953) and HEAD (493b641). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (c773953) HEAD (493b641)
cubesql 1 0
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #10607       +/-   ##
===========================================
- Coverage   78.58%   57.91%   -20.68%     
===========================================
  Files         475      225      -250     
  Lines       92831    17587    -75244     
  Branches     3614     3614               
===========================================
- Hits        72954    10185    -62769     
+ Misses      19333     6858    -12475     
  Partials      544      544               
Flag Coverage Δ
cube-backend 57.91% <100.00%> (ø)
cubesql ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update Javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants