Spaces:
Sleeping
Sleeping
Update analytics/recommendation_logger.py
Browse files
analytics/recommendation_logger.py
CHANGED
|
@@ -56,4 +56,46 @@ def build_recommendation_log_rows(
|
|
| 56 |
}
|
| 57 |
)
|
| 58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
return pd.DataFrame(rows)
|
|
|
|
| 56 |
}
|
| 57 |
)
|
| 58 |
|
| 59 |
+
return pd.DataFrame(rows)
|
| 60 |
+
|
| 61 |
+
def build_recommendation_outcome_rows(
|
| 62 |
+
game_row: dict[str, Any],
|
| 63 |
+
graded_at: str,
|
| 64 |
+
) -> pd.DataFrame:
|
| 65 |
+
"""
|
| 66 |
+
Placeholder outcome scaffold.
|
| 67 |
+
Realized fields are left null until a later grading source is connected.
|
| 68 |
+
"""
|
| 69 |
+
away_team = str(game_row.get("away_team", "") or "").strip()
|
| 70 |
+
home_team = str(game_row.get("home_team", "") or "").strip()
|
| 71 |
+
game_pk = str(game_row.get("game_pk", "") or "").strip()
|
| 72 |
+
|
| 73 |
+
rows = []
|
| 74 |
+
|
| 75 |
+
for slot_key, slot_label in [
|
| 76 |
+
("on_deck_name", "On Deck"),
|
| 77 |
+
("in_hole_name", "In Hole"),
|
| 78 |
+
("three_away_name", "3 Away"),
|
| 79 |
+
]:
|
| 80 |
+
batter_name = str(game_row.get(slot_key, "") or "").strip()
|
| 81 |
+
if not batter_name:
|
| 82 |
+
continue
|
| 83 |
+
|
| 84 |
+
rows.append(
|
| 85 |
+
{
|
| 86 |
+
"created_at": None,
|
| 87 |
+
"game_pk": game_pk,
|
| 88 |
+
"away_team": away_team,
|
| 89 |
+
"home_team": home_team,
|
| 90 |
+
"batter_name": batter_name,
|
| 91 |
+
"slot": slot_label,
|
| 92 |
+
"market": "hr",
|
| 93 |
+
"realized_hit": None,
|
| 94 |
+
"realized_hr": None,
|
| 95 |
+
"realized_tb2p": None,
|
| 96 |
+
"graded_at": graded_at,
|
| 97 |
+
"outcome_source": "placeholder",
|
| 98 |
+
}
|
| 99 |
+
)
|
| 100 |
+
|
| 101 |
return pd.DataFrame(rows)
|