Skip to content

Commit 8d6bfb9

Browse files
committed
showing the newest feeds first while still considering search relevance when a search term is provided
1 parent 75cfd12 commit 8d6bfb9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

api/src/feeds/impl/search_api_impl.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,14 @@ def create_search_query(
119119
query = SearchApiImpl.add_search_query_filters(
120120
query, search_query, data_type, feed_id, status, is_official, features, version
121121
)
122-
return query.order_by(rank_expression.desc())
122+
# If search query is provided, use it as secondary sort after timestamp
123+
if search_query and len(search_query.strip()) > 0:
124+
return query.order_by(
125+
t_feedsearch.c.created_at.desc(), # Primary sort: newest first
126+
rank_expression.desc(), # Secondary sort: relevance
127+
)
128+
else:
129+
return query.order_by(t_feedsearch.c.created_at.desc())
123130

124131
@with_db_session
125132
def search_feeds(

0 commit comments

Comments
 (0)