plane icon indicating copy to clipboard operation
plane copied to clipboard

[WIKI-769] chore: added sort order for pages

Open NarayanBavisetti opened this issue 1 month ago β€’ 2 comments

Description

added sorting of page in project level pages.

Type of Change

  • [x] Feature (non-breaking change which adds functionality)

Summary by CodeRabbit

Release Notes

  • New Features
    • Page sort order now exposed in API responses for improved ordering and management capabilities
    • New pages automatically assigned sort order values when created within a project
    • Existing pages updated with sort order values during system upgrade to ensure data consistency

✏️ Tip: You can customize this high-level summary in your review settings.

NarayanBavisetti avatar Nov 27 '25 12:11 NarayanBavisetti

Walkthrough

This change introduces a sort_order field to ProjectPage for managing page sorting within projects. A database migration populates existing data with robust duplicate-handling logic, the model initializes sort orders for new pages, the view prefetches related data, and the serializer exposes the computed sort order value.

Changes

Cohort / File(s) Summary
Database Schema & Migration
apps/api/plane/db/migrations/0113_auto_20251215_0934.py
Adds sort_order FloatField to ProjectPage with default 65535. Includes set_page_sort_order() function that copies parent sort orders and resolves duplicates by workspace with batched updates. Includes reverse migration reverse_set_page_sort_order().
Model Layer
apps/api/plane/db/models/page.py
Adds sort_order FloatField field to ProjectPage. Introduces _set_sort_for_root_page() initialization method and overrides save() to auto-set sort order for new root pages.
View & Serializer Layer
apps/api/plane/app/views/page/base.py, apps/api/plane/app/serializers/page.py
View adds Prefetch for current-project filtered project_pages relation. Serializer adds sort_order SerializerMethodField with get_sort_order() method that returns prefetched data or DEFAULT_SORT_ORDER fallback.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Migration logic: Batched bulk operations with duplicate detection and per-workspace sort-order reassignment require careful verification
  • Model initialization: _set_sort_for_root_page() logic for computing new sort orders based on project-wide maximums needs validation
  • Prefetch setup: Confirm filter conditions and relation assumptions in view's get_queryset()
  • Serializer fallback: Verify the prefetch relation is always available when accessed in get_sort_order()

Poem

🐰 A new sort order hops into place, Pages now dance with numeric grace, Prefetch and serialize, side by side, Duplicates handled with batched pride, Organization's our rabbit delight! 🌟

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete. While it identifies the feature and indicates the type of change, it lacks detail on implementation specifics, test scenarios, and references to related issues. Expand the description to explain how sort order works, add specific test scenarios, and include a reference to issue WIKI-769 linked in the title.
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
βœ… Passed checks (1 passed)
Check name Status Explanation
Title check βœ… Passed The title accurately describes the main change: adding sort order functionality for pages. It is concise and clearly summarizes the primary modification across the changeset.
✨ Finishing touches
  • [ ] πŸ“ Generate docstrings
πŸ§ͺ Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment
  • [ ] Commit unit tests in branch chore-page-sort-order

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

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

coderabbitai[bot] avatar Nov 27 '25 12:11 coderabbitai[bot]

Linked to Plane Work Item(s)

This comment was auto-generated by Plane

makeplane[bot] avatar Nov 27 '25 12:11 makeplane[bot]