Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion front_end/src/app/(main)/questions/helpers/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ const EXPLICIT_FEED_FILTER_KEYS = [
POST_NOT_FORECASTER_ID_FILTER,
POST_PROJECT_FILTER,
POST_STATUS_FILTER,
POST_TEXT_SEARCH_FILTER,
POST_TOPIC_FILTER,
POST_TYPE_FILTER,
POST_UPVOTED_BY_FILTER,
Expand Down
21 changes: 17 additions & 4 deletions posts/services/feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ def get_posts_feed( # noqa: C901

# Apply consumer views filter
if for_consumer_view:
qs = filter_for_consumer_view(qs)
# When the user is searching, keep resolved posts in the result set so
# they can still find questions by title regardless of resolution state.
qs = filter_for_consumer_view(qs, include_resolved=bool(search))

# Exclude Deleted posts
qs = qs.exclude(curation_status=Post.CurationStatus.DELETED)
Expand Down Expand Up @@ -333,7 +335,9 @@ def get_posts_feed( # noqa: C901
return qs.distinct("id", order_type).only("pk")


def filter_for_consumer_view(qs: QuerySet[Post]) -> QuerySet[Post]:
def filter_for_consumer_view(
qs: QuerySet[Post], include_resolved: bool = False
) -> QuerySet[Post]:
"""
A special filter applied to default Consumer View feed representation
https://github.com/Metaculus/metaculus/issues/3377
Expand Down Expand Up @@ -370,8 +374,17 @@ def filter_for_consumer_view(qs: QuerySet[Post]) -> QuerySet[Post]:
)
)

# Exclude resolved questions
qs = qs.exclude(resolved=True)
# Exclude resolved questions (unless the caller explicitly wants them, e.g.
# for search results where the user is looking up a specific question).
if not include_resolved:
qs = qs.exclude(resolved=True)

# Exclude AIB / bots-only tournaments — the same questions are typically
# cross-posted in a human-facing project (Metaculus Cup etc.), so showing
# them here produces duplicate-looking search results.
qs = qs.exclude(
default_project__bot_leaderboard_status=Project.BotLeaderboardStatus.BOTS_ONLY
)

return qs

Expand Down
Loading