fix(experiments): enable server sorting for list columns#6
Open
lordspline wants to merge 2 commits into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Experiments list exposed sortable
ResultandCreated bycolumns, but clicking them sentorder=conclusionandorder=created_byto the list API. Those order values were not both handled safely server-side, so users saw API errors instead of global sorting.Fixes PostHog#63621
Changes
created_byand a deterministicconclusionsort key matching the displayed result order.How did you test this code?
As an agent, I tested this with:
SANDBOX_PROVIDER= TEST=1 DEBUG=1 POSTHOG_TELEMETRY_OPT_OUT=1 pytest -s products/experiments/backend/test/test_experiment_service.py products/experiments/backend/test/test_presentation_api.py -k "orders_by_conclusion or orders_by_created_by or order_by_valid_fields_works or can_order_experiments_by"pnpm --filter=@posthog/frontend exec jest frontend/src/scenes/experiments/experimentsLogic.test.ts --runInBand --forceExitruff format --check products/experiments/backend/experiment_service.py products/experiments/backend/presentation/views.py products/experiments/backend/test/test_experiment_service.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_experiment_service.py products/experiments/backend/test/test_presentation_api.pypnpm exec oxfmt --check frontend/src/scenes/experiments/Experiments.tsx frontend/src/scenes/experiments/experimentsLogic.test.ts products/experiments/frontend/generated/api.schemas.ts services/mcp/src/api/generated.ts services/mcp/src/generated/experiments/api.ts && pnpm exec oxlint --quiet frontend/src/scenes/experiments/Experiments.tsx frontend/src/scenes/experiments/experimentsLogic.test.ts products/experiments/frontend/generated/api.schemas.ts services/mcp/src/api/generated.ts services/mcp/src/generated/experiments/api.tspnpm --filter=@posthog/frontend typescript:checkhttp://localhost:8010: seeded six Experiments rows, clickedResultascending/descending andCreated byascending/descending, and confirmed the four API requests returned HTTP 200 with no experiment-list API errors.Automatic notifications
Docs update
No docs update needed; this fixes existing Experiments list sorting behavior.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Implemented by Capy after a human request to fix the Experiments list sorting issue end to end. I kept
ResultandCreated byglobally server-sorted instead of disabling them or sorting only the current page, because LemonTable was already emitting those order keys and the list API owns pagination. The main backend choice was to mapconclusionto the same deterministic display order the old client-side sorter used, and to makecreated_bysort through a typed display-name expression so null creators and mixed name/email field types do not error.Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.