Add featured projects to default sort on Explore Projects page#7230
Open
wtomeo46 wants to merge 1 commit into
Open
Add featured projects to default sort on Explore Projects page#7230wtomeo46 wants to merge 1 commit into
wtomeo46 wants to merge 1 commit into
Conversation
Featured projects now appear between Urgent and High priority in the default sort order when no explicit order_by is specified, implementing the tier ordering: Urgent > Featured > High > Medium > Low. Adds p.featured to the SELECT clause and a default ORDER BY clause that encodes the new sort tiers via a CASE expression. The existing override behavior for explicit order_by parameters is preserved. Includes a unit test verifying the new default sort order. Closes hotosm#6704
|
|
Great, how would the featured attribute be added to projects? Just by Tasking Manager admins? |
Author
|
Yes, as already set, only admin users can set the featured attribute through the project edit page as access is gated by UserRole.ADMIN. |
|
Fantastic @wtomeo46! Great |
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.



What
Implements issue #6704 by adding "featured" projects to the default sort order on the Explore Projects page. When no explicit
order_byparameter is supplied, projects are now sorted in the following order:Urgent → Featured → High → Medium → Low
Why
As described in #6704, the Explore Projects page currently defaults to sorting by priority, with older projects appearing first within each priority group. This means the front page is often dominated by outdated projects and beginner-friendly projects are hard to find. The "featured" flag had no effect on the default sort. This PR makes featured projects discoverable in the default view by placing them in their own prioritized tier.
How
Two small changes in
backend/services/project_search_service.py:p.featuredto the project search query to be available for ordering.order_by_clausewith aCASEexpression that orders the five tiers. The existing logic that overridesorder_by_clausewhensearch_dto.order_byis provided is preserved.Testing
Added
test_default_sort_order_places_featured_between_urgent_and_highintests/api/unit/services/test_project_search_service.py. The test initializes 4 projects covering each tier (urgent, featured-high, plain-high, medium) and asserts that search service returns them in the expected order when noorder_byis supplied.To run:
'uv run python -m pytest tests/api/unit/services/test_project_search_service.py -v'
All 4 tests in that file pass locally.