Skip to content

Comments

Code Review Bench PR #25719 - Added materialized view and duplicated v2 Tinybird endpoints#14

Open
ketkarameya wants to merge 13 commits intobase_pr_25719_20260125_2049from
corrupted_pr_25719_20260125_2049
Open

Code Review Bench PR #25719 - Added materialized view and duplicated v2 Tinybird endpoints#14
ketkarameya wants to merge 13 commits intobase_pr_25719_20260125_2049from
corrupted_pr_25719_20260125_2049

Conversation

@ketkarameya
Copy link

@ketkarameya ketkarameya commented Feb 10, 2026

Code Review Bench PR TryGhost#25719 - Added materialized view and duplicated v2 Tinybird endpoints

Benchmark PR for Gitar evaluation

Original PR: agentic-review-benchmarks#13

Adds materialized view and duplicates v2 Tinybird endpoints for performance optimization.


Summary by Gitar

  • Analytics Infrastructure: Created 12 v2 analytics endpoints (api_kpis_v2, api_active_visitors_v2, api_post_visitor_counts_v2, api_top_devices_v2, api_top_locations_v2, api_top_pages_v2, api_top_sources_v2, and 5 utm-related endpoints) using ClickHouse materialized views with AggregatingMergeTree for pre-computed session aggregation
  • Materialized View Datasource: Introduced _mv_session_data_v2 datasource with state/merge aggregator pattern (countState/countMerge, minState/minMerge, argMinState/argMinMerge) enabling distributed aggregation and optimized query performance
  • Configuration Versioning: Implemented optional version parameter in StatsConfig interface for runtime endpoint selection, allowing dynamic switching between v1 and v2 analytics endpoints via configuration
  • Service Integration: Updated TinybirdService to include v2 pipes in JWT token generation, refactored ContentStatsService to use config-based versioning, and enhanced tinybird utilities to construct versioned endpoint URLs
  • Backward Compatibility: Maintained full compatibility through optional version parameter with sensible defaults, preserving all v1 endpoints unchanged while enabling opt-in v2 optimizations

@gitar-bot-staging
Copy link

gitar-bot-staging bot commented Feb 10, 2026

Code Review 🚫 Blocked 0 resolved / 1 findings

Well-structured v2 analytics optimization with one critical bug: the frontend URL builder reverses the version suffix order (v2_api_kpis instead of api_kpis_v2), which will break all admin analytics API calls when v2 is configured.

🚨 Bug: Frontend version prefix is reversed, producing wrong endpoint URLs

📄 apps/admin-x-framework/src/utils/stats-config.ts:18

The frontend URL builder in stats-config.ts constructs the versioned endpoint name as ${config.version}_${endpointName} (version prefix), which produces URLs like /v0/pipes/v2_api_kpis.json. However, the backend URL builder in tinybird.js uses ${pipeName}_${version} (version suffix), producing /v0/pipes/api_kpis_v2.json, which matches the actual Tinybird pipe names (e.g., api_kpis_v2.pipe).

This means when version: "v2" is configured, the admin frontend will request completely wrong endpoint names (e.g., v2_api_kpis instead of api_kpis_v2), causing all analytics API calls from the admin panel to fail with 404 errors.

Suggested fix
    const finalEndpointName = config.version ? `${endpointName}_${config.version}` : endpointName;
Rules 🎸 1 action taken

Gitar Rules

🎸 Summary Enhancement: PR description enhanced with 5-point technical summary covering v2 endpoint infrastructure, materialized view datasource, configuration versioning, service integration, and backward compatibility

5 rules not applicable. Show all rules by commenting gitar display:verbose.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

return `${baseUrl}/v0/pipes/${endpointName}.json?${params}`;

// Append version suffix if provided (e.g., "v2" -> "api_kpis_v2")
const finalEndpointName = config.version ? `${config.version}_${endpointName}` : endpointName;

Choose a reason for hiding this comment

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

🚨 Bug: Frontend version prefix is reversed, producing wrong endpoint URLs

The frontend URL builder in stats-config.ts constructs the versioned endpoint name as ${config.version}_${endpointName} (version prefix), which produces URLs like /v0/pipes/v2_api_kpis.json. However, the backend URL builder in tinybird.js uses ${pipeName}_${version} (version suffix), producing /v0/pipes/api_kpis_v2.json, which matches the actual Tinybird pipe names (e.g., api_kpis_v2.pipe).

This means when version: "v2" is configured, the admin frontend will request completely wrong endpoint names (e.g., v2_api_kpis instead of api_kpis_v2), causing all analytics API calls from the admin panel to fail with 404 errors.

Was this helpful? React with 👍 / 👎

Suggested change
const finalEndpointName = config.version ? `${config.version}_${endpointName}` : endpointName;
const finalEndpointName = config.version ? `${endpointName}_${config.version}` : endpointName;
  • Apply suggested fix

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.

3 participants