Skip to content

Merge template_usage_stats *_mins into app_usage_mins JSONB #27413

Description

@EhabY

Phase 4 of the Scalable Approach for Adding New IDE Session Types RFC. The durable template_usage_stats table still has dedicated vscode_mins/jetbrains_mins/ssh_mins/reconnecting_pty_mins columns, so adding an IDE would still require a schema change there; this phase makes the durable rollup layer dynamic too.

Scope (RFC: "template_usage_stats must also be migrated"):

  • UpsertTemplateUsageStats: have the agent_stats_buckets CTE produce app_name/app_minutes entries that flow into the existing app_usage_mins JSONB, the same way web app usage is stored today
  • Key scheme: builtin session names will share app_usage_mins with web app slugs; confirm how the insights queries tell them apart before writing the backfill
  • One-time migration: backfill the dedicated *_mins values into app_usage_mins for existing rows, then drop the dedicated columns, including the always-zero sftp_mins (dead since its TODOs were never implementable)
  • GetTemplateInsights: read IDE minutes from app_usage_mins instead of dedicated columns; convertTemplateInsightsApps builds the builtin apps list dynamically
  • GetTemplateAppInsights stays separate (it filters via workspace_apps, which builtin IDE sessions never join)

After this phase, a new IDE flows agent → normalized table → JSONB rollup with zero schema changes, which is the point of the RFC.

Done when

  • Rollup writes IDE minutes into app_usage_mins and the dedicated columns are dropped
  • Backfilled historical data produces identical GetTemplateInsights results
  • A new app name reported through phase 1 shows up in template insights with no schema change

Depends on #27410.


🤖 Created by Coder Agents on behalf of @EhabY.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions