Fix: enhancement - custom sort home rows (#1) #2

Closed
tobias.hertel wants to merge 1 commit from fix/1-custom-sort-home-rows into main

Summary

This PR implements configurable row ordering for home screen recommendation rows, addressing issue #1.

What was the issue

Users could not explicitly specify a custom sort order for the recommendation rows displayed on the home screen. Rows were ordered solely by their position in the config file list, with no way to control their display order independently.

What was changed

  1. src/plex_middleware/config.py: Added an optional order field to RecommendationRowSettings. The field accepts an integer or None (default), allowing users to specify explicit sort positions.

  2. src/plex_middleware/recommendations.py: Updated _sorted_rows() to sort rows by their explicit order value (ascending). Rows without an order value fall back to the original config list order, ensuring backward compatibility.

  3. config.example.yml: Added order examples for both Movie and TV recommendation sections.

  4. tests/test_recommendations.py: Added 5 new tests:

    • test_sorted_rows_with_explicit_order - verifies rows are sorted by order values
    • test_sorted_rows_without_explicit_order_preserves_list_position - verifies backward compatibility
    • test_sorted_rows_mix_order_and_no_order - verifies mixed scenarios (ordered + unordered rows)
    • test_order_field_is_optional_and_defaults_to_none - verifies the field is optional
    • test_reconciliation_uses_explicit_order_for_moves - verifies end-to-end reconciliation with ordering

How to use

Add an order field to any recommendation row in your config file:

libraries:
  - section_id: 1
    rows:
      - identifier: movie.popular
        order: 10
      - identifier: movie.topunwatched
        order: 20
      - identifier: movie.recentlyadded  # no order - keeps config position

Lower order values appear first. Rows without order maintain their original config position after all ordered rows.

Verification

Run the test suite:

uv run pytest tests/test_recommendations.py -v

All 10 tests pass, including the 5 new tests for ordering behavior.

## Summary This PR implements configurable row ordering for home screen recommendation rows, addressing issue #1. ### What was the issue Users could not explicitly specify a custom sort order for the recommendation rows displayed on the home screen. Rows were ordered solely by their position in the config file list, with no way to control their display order independently. ### What was changed 1. **`src/plex_middleware/config.py`**: Added an optional `order` field to `RecommendationRowSettings`. The field accepts an integer or `None` (default), allowing users to specify explicit sort positions. 2. **`src/plex_middleware/recommendations.py`**: Updated `_sorted_rows()` to sort rows by their explicit `order` value (ascending). Rows without an `order` value fall back to the original config list order, ensuring backward compatibility. 3. **`config.example.yml`**: Added `order` examples for both Movie and TV recommendation sections. 4. **`tests/test_recommendations.py`**: Added 5 new tests: - `test_sorted_rows_with_explicit_order` - verifies rows are sorted by order values - `test_sorted_rows_without_explicit_order_preserves_list_position` - verifies backward compatibility - `test_sorted_rows_mix_order_and_no_order` - verifies mixed scenarios (ordered + unordered rows) - `test_order_field_is_optional_and_defaults_to_none` - verifies the field is optional - `test_reconciliation_uses_explicit_order_for_moves` - verifies end-to-end reconciliation with ordering ### How to use Add an `order` field to any recommendation row in your config file: ```yaml libraries: - section_id: 1 rows: - identifier: movie.popular order: 10 - identifier: movie.topunwatched order: 20 - identifier: movie.recentlyadded # no order - keeps config position ``` Lower `order` values appear first. Rows without `order` maintain their original config position after all ordered rows. ### Verification Run the test suite: ```bash uv run pytest tests/test_recommendations.py -v ``` All 10 tests pass, including the 5 new tests for ordering behavior.
- Add 'order' field to RecommendationRowSettings (optional, defaults to None)
- Update _sorted_rows() to sort rows by explicit 'order' value when set
- Rows without 'order' fall back to original config list order
- Update config.example.yml with order examples for Movie and TV sections
- Add unit tests for explicit ordering, default ordering, and mixed scenarios
- Add integration test verifying reconciliation moves rows by explicit order
tobias.hertel closed this pull request 2026-10-10 13:55:25 +02:00
tobias.hertel deleted branch fix/1-custom-sort-home-rows 2026-10-10 13:55:34 +02:00

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
tobias.hertel/plex-middleware!2
No description provided.