Skip to content

fix(experiments): support result and creator list ordering#22

Open
justinsunyt wants to merge 4 commits into
masterfrom
capy/fix-experiment-list-sort
Open

fix(experiments): support result and creator list ordering#22
justinsunyt wants to merge 4 commits into
masterfrom
capy/fix-experiment-list-sort

Conversation

@justinsunyt

@justinsunyt justinsunyt commented Jun 19, 2026

Copy link
Copy Markdown

Problem

Sorting the Experiments list by Result sent order=conclusion, which the API rejected, and sorting by Created by could raise a server error while building the database ordering expression.

Fixes PostHog#63621

Changes

  • Allow conclusion / -conclusion as experiment list order fields and sort them in the same display order as the UI.
  • Make created_by ordering use an explicit string output field and fall back to an empty value when the creator is missing.
  • Add regression coverage for ascending and descending Result and Created by ordering.

How did you test this code?

As an agent, I tested this with:

  • ruff format products/experiments/backend/experiment_service.py products/experiments/backend/presentation/views.py products/experiments/backend/test/test_presentation_api.py
  • ruff check products/experiments/backend/experiment_service.py products/experiments/backend/presentation/views.py products/experiments/backend/test/test_presentation_api.py --fix
  • hogli test products/experiments/backend/test/test_presentation_api.py --maxfail=1 -q -k "test_can_order_experiments_by_conclusion or test_can_order_experiments_by_created_by" with SANDBOX_PROVIDER unset for the local test environment
  • Browser verification on local PostHog: clicked Result and Created by sorting on seeded Experiments rows and confirmed the URL/table updated without a load/server error.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Docs update

No docs update needed; this fixes API sorting behavior for an existing UI.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Captain Capy implemented the fix after reproducing the invalid conclusion order error and tracing the existing created_by ordering expression. The change keeps sorting server-side so paginated Experiment list requests remain consistent with the table headers.

Open POST-074 POST-074


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

justinsunyt and others added 2 commits June 19, 2026 04:41
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@justinsunyt justinsunyt added the capy Generated by capy.ai label Jun 19, 2026 — with Capy AI
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

capy Generated by capy.ai

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug Report: Filtering the experiment list by Result or Created By causes the sort to break.

2 participants