Skip to content

[codex] Show admin trial extension badges#1917

Merged
riderx merged 1 commit intomainfrom
codex/admin-trial-extension-badges
Apr 16, 2026
Merged

[codex] Show admin trial extension badges#1917
riderx merged 1 commit intomainfrom
codex/admin-trial-extension-badges

Conversation

@riderx
Copy link
Copy Markdown
Member

@riderx riderx commented Apr 15, 2026

Summary (AI generated)

  • add trial_extension_count to the admin trial organizations query based on 15-day extensions beyond the initial trial window
  • show an Extended {count} badge in the admin users trial table when a trial has been extended
  • cover the new extension-count behavior in the admin stats test fixture and assertion

Motivation (AI generated)

The admin users trial tab highlighted organizations that are close to expiry, but it did not show whether a trial had already been extended. That hid useful context for follow-up and made extended trials look the same as first-time trials.

Business Impact (AI generated)

This gives the Capgo team clearer billing and follow-up context in the admin dashboard, which should reduce manual investigation and help support or sales understand whether a trial has already received extra time.

Test Plan (AI generated)

  • bun lint
  • bun lint:backend
  • bun typecheck
  • bun run supabase:with-env -- bunx vitest run tests/admin-stats.test.ts

Generated with AI

Summary by CodeRabbit

  • New Features

    • Added a trial extension badge to the admin dashboard that displays the number of times an organization's trial has been extended.
  • Tests

    • Added test coverage for the trial extension count feature.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ee0fa50e-78ae-45dd-9751-726657f7d544

📥 Commits

Reviewing files that changed from the base of the PR and between 0d4b724 and e21a871.

📒 Files selected for processing (4)
  • messages/en.json
  • src/pages/admin/dashboard/users.vue
  • supabase/functions/_backend/utils/pg.ts
  • tests/admin-stats.test.ts

📝 Walkthrough

Walkthrough

This change adds trial extension tracking and display to the admin dashboard. A new translation key is introduced, the trial organizations interface is extended with a trial_extension_count field, backend SQL logic computes the extension count based on trial dates, and the UI renders a styled badge displaying the count.

Changes

Cohort / File(s) Summary
Translation Updates
messages/en.json
Added new translation key trial-extended-badge with value "Extended {count}" for badge display.
Admin UI Updates
src/pages/admin/dashboard/users.vue
Updated TrialOrganization interface to include trial_extension_count: number. Added custom render function for organization name column that conditionally displays a styled "trial extended" badge when count > 0, using helper function getTrialExtensionBadgeLabel() to generate localized labels.
Backend Computation
supabase/functions/_backend/utils/pg.ts
Extended AdminTrialOrganization interface with trial_extension_count field. Modified getAdminTrialOrganizations() SQL query to compute extension count via CASE expression: calculates (trial_at - created_at) / 15 days when difference exceeds 15, else 0. Maps computed value to result objects.
Test Updates
tests/admin-stats.test.ts
Added TRIAL_ORG_CREATED_AT timestamp constant and inserted into test fixture. Updated expected response type to include trial_extension_count: number and asserted trial organization returns trial_extension_count of 2.

Sequence Diagram

sequenceDiagram
    actor Admin
    participant Vue as Admin Dashboard<br/>(users.vue)
    participant Backend as Supabase Functions<br/>(pg.ts)
    participant DB as Database

    Admin->>Vue: Access admin dashboard
    Vue->>Backend: Request trial organizations data
    Backend->>DB: Query organizations with trial metadata<br/>(created_at, si.trial_at)
    DB-->>Backend: Return org records
    Backend->>Backend: Compute trial_extension_count<br/>CASE (trial_at - created_at) / 15
    Backend-->>Vue: Return orgs with trial_extension_count
    Vue->>Vue: For each org with count > 0:<br/>Render org name + badge
    Vue->>Vue: Get badge label:<br/>t('trial-extended-badge', {count})
    Vue-->>Admin: Display trial organizations<br/>with extension badges
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A badge hops into view,
Counting trials extended, shiny and new,
With trial_at and created_at we calculate true,
Dividing by fifteen, what magic we brew!
Extended trials now shine for the crew! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding admin trial extension badges to the interface.
Description check ✅ Passed The description covers the summary, motivation, and business impact well, and includes a test plan with checkmarks indicating verification.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/admin-trial-extension-badges

Comment @coderabbitai help to get the list of available commands and usage tips.

@codspeed-hq
Copy link
Copy Markdown
Contributor

codspeed-hq bot commented Apr 15, 2026

Merging this PR will not alter performance

✅ 28 untouched benchmarks


Comparing codex/admin-trial-extension-badges (e21a871) with main (0d4b724)

Open in CodSpeed

@riderx riderx marked this pull request as ready for review April 15, 2026 20:07
@sonarqubecloud
Copy link
Copy Markdown

@riderx riderx merged commit 0b67b60 into main Apr 16, 2026
15 checks passed
@riderx riderx deleted the codex/admin-trial-extension-badges branch April 16, 2026 09:43
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