feat: link tackle analytics to canonical gear
This commit is contained in:
@@ -56,6 +56,20 @@ def tackle_combinations(
|
||||
result = []
|
||||
for (role, value), reports in groups.items():
|
||||
unique_reports = {report.id: report for report in reports}
|
||||
item_ids = {
|
||||
component.tackle_item_id
|
||||
for report in unique_reports.values()
|
||||
for component in report.tackle_components
|
||||
if component.role == role and component.raw_value.strip() == value and component.tackle_item_id is not None
|
||||
}
|
||||
rig_ids = {
|
||||
component.rig_id
|
||||
for report in unique_reports.values()
|
||||
for component in report.tackle_components
|
||||
if component.role == role and component.raw_value.strip() == value and component.rig_id is not None
|
||||
}
|
||||
canonical_item_id = next(iter(item_ids)) if len(item_ids) == 1 and not rig_ids else None
|
||||
canonical_rig_id = next(iter(rig_ids)) if len(rig_ids) == 1 and not item_ids else None
|
||||
players = {report.player_name.strip().casefold() for report in unique_reports.values() if report.player_name and report.player_name.strip()}
|
||||
catches = len(unique_reports)
|
||||
unique_players = len(players)
|
||||
@@ -66,7 +80,8 @@ def tackle_combinations(
|
||||
) / catches * 100)
|
||||
enough = catches >= min_samples and unique_players >= min_players
|
||||
result.append(TackleCombinationOut(
|
||||
role=role, value=value, catches=catches, unique_players=unique_players,
|
||||
role=role, value=value, tackle_item_id=canonical_item_id, rig_id=canonical_rig_id,
|
||||
catches=catches, unique_players=unique_players,
|
||||
last_seen_at=last_seen, freshness_score=freshness_score,
|
||||
status="recommendation" if enough else "insufficient_data",
|
||||
explanation=(
|
||||
|
||||
@@ -115,6 +115,8 @@ class PaginatedActivityOut(BaseModel):
|
||||
class TackleCombinationOut(BaseModel):
|
||||
role: str
|
||||
value: str
|
||||
tackle_item_id: UUID | None = None
|
||||
rig_id: UUID | None = None
|
||||
catches: int
|
||||
unique_players: int
|
||||
last_seen_at: datetime
|
||||
|
||||
Reference in New Issue
Block a user