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
3 changes: 3 additions & 0 deletions questions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,9 @@ def exclude_non_primary_bots(self):
Q(author__is_bot=False) | Q(author__is_primary_bot=True),
)

def exclude_blacklisted_users(self):
return self.filter(author__exclude_from_aggregations=False)

def active(self):
"""
Returns active forecasts.
Expand Down
1 change: 1 addition & 0 deletions scoring/score_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ def evaluate_question(
if not only_include_user_ids:
# only include forecasts by non-primary bots if user ids explicitly specified
base_forecasts = base_forecasts.exclude_non_primary_bots()
base_forecasts = base_forecasts.exclude_blacklisted_users()
if not question.include_bots_in_aggregates:
Comment thread
lsabor marked this conversation as resolved.
base_forecasts = base_forecasts.exclude(author__is_bot=True)
aggregations = get_aggregation_history(
Expand Down
2 changes: 2 additions & 0 deletions users/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ class UserAdmin(admin.ModelAdmin):
"is_spam",
"is_bot",
"is_primary_bot",
"exclude_from_aggregations",
"bot_owner",
"duration_joined_to_last_login",
"authored_posts",
Expand All @@ -234,6 +235,7 @@ class UserAdmin(admin.ModelAdmin):
list_filter = [
"is_active",
"is_spam",
"exclude_from_aggregations",
"date_joined",
LastLoginFilter,
AuthoredPostsFilter,
Expand Down
25 changes: 25 additions & 0 deletions users/migrations/0021_user_exclude_from_aggregations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 5.2.12 on 2026-05-21 21:16

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("users", "0020_api_forecasting_access"),
]

operations = [
migrations.AddField(
model_name="user",
name="exclude_from_aggregations",
field=models.BooleanField(
db_index=True,
default=False,
help_text=(
"Explicitly excludes this user from aggregations and geometric "
"mean for peer scoring, regardless of bot status."
),
),
),
]
10 changes: 10 additions & 0 deletions users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ class InterfaceType(models.TextChoices):
),
)

# Aggregation exclusion
exclude_from_aggregations = models.BooleanField(
default=False,
db_index=True,
help_text=(
"Explicitly excludes this user from aggregations and geometric mean for "
"peer scoring, regardless of bot status."
),
)

# Bot properties
is_bot = models.BooleanField(default=False, db_index=True)
is_primary_bot = models.BooleanField(
Expand Down
8 changes: 6 additions & 2 deletions utils/the_math/aggregations.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,8 +748,10 @@ def get_aggregations_at_time(
if only_include_user_ids:
forecasts = forecasts.filter(author_id__in=only_include_user_ids)
else:
# only include forecasts by non-primary bots if user ids explicitly specified
# only include forecasts by non-primary bots or blacklisted users
# if user ids explicitly specified
forecasts = forecasts.exclude_non_primary_bots()
forecasts = forecasts.exclude_blacklisted_users()
if not include_bots:
Comment thread
lsabor marked this conversation as resolved.
forecasts = forecasts.exclude(author__is_bot=True)
if len(forecasts) == 0:
Expand Down Expand Up @@ -1000,8 +1002,10 @@ def get_aggregation_history(
if only_include_user_ids:
forecasts = forecasts.filter(author_id__in=only_include_user_ids)
else:
# only include forecasts by non-primary bots if user ids explicitly specified
# only include forecasts by non-primary bots or blacklisted users
# if user ids explicitly specified
forecasts = forecasts.exclude_non_primary_bots()
forecasts = forecasts.exclude_blacklisted_users()
if not include_bots:
forecasts = forecasts.exclude(author__is_bot=True)

Expand Down
Loading