@@ -1332,7 +1332,7 @@ def task_score(
13321332 if requirements .location in ctx .member .preferred_rooms :
13331333 score .multiply_score (1.5 , f"'{ requirements .location } ' is a preferred room for the member" )
13341334 else :
1335- score .multiply_score (0.1 , f"'{ requirements .location } ' isn't a preferred room for the member" )
1335+ score .multiply_score (0.05 , f"'{ requirements .location } ' isn't a preferred room for the member" )
13361336
13371337 # Score: (weight * frequency * (1 + overdue_frequency_intervals)) / (how many members in the past 30 days have been assignable to this task)
13381338 # Can be assigned task: (last completed task size) - (hours spent at space since last completed task)
@@ -1683,7 +1683,6 @@ def send_slack_message_to_member(
16831683
16841684
16851685def select_card_for_member (ctx : TaskContext , ignore_reasons : list [str ]) -> Optional [trello .TrelloCard ]:
1686- member_id = ctx .member .member_id
16871686 visits = visit_events_by_member_id (datetime .now () - timedelta (days = 30 ), datetime .now ())
16881687
16891688 ASSIGN_DELAY = timedelta (minutes = 3 )
@@ -1721,6 +1720,14 @@ def select_card_for_member(ctx: TaskContext, ignore_reasons: list[str]) -> Optio
17211720 reverse = True ,
17221721 )
17231722
1723+ # Filter out scores that are lower than 5% of the maximum to avoid long-tail picks
1724+ if scores :
1725+ max_score = scores [0 ][1 ].score
1726+ threshold = max_score * 0.05
1727+ for s in scores :
1728+ if s [1 ].score < threshold and s [1 ].cannot_be_assigned_reason is None :
1729+ s [1 ].multiply_score (0.0 , f"Long tail filter (below { threshold :.1f} )" )
1730+
17241731 for card , score in scores :
17251732 # Use reservoir sampling to pick a card randomly with weights
17261733 assert score .score >= 0
0 commit comments