(self)
| 537 | self._records = [r for r in self._records if r.timestamp >= cutoff_ts] |
| 538 | |
| 539 | def _load(self) -> None: |
| 540 | rows = self._storage.load_recent_days(self._hot_days, now=self._now()) |
| 541 | traces: dict[str, RequestTrace] = {} |
| 542 | order: list[str] = [] |
| 543 | for row in rows: |
| 544 | if not isinstance(row, dict): |
| 545 | continue |
| 546 | rtype = row.get("type", "trace") |
| 547 | if rtype == "trace": |
| 548 | rid = str(row.get("request_id", "")) |
| 549 | if not rid: |
| 550 | continue |
| 551 | # Drop cold fields when constructing the hot record. |
| 552 | hot_row = {k: v for k, v in row.items() if k != "type" and k not in COLD_FIELDS} |
| 553 | # Backfill cold field defaults for the dataclass. |
| 554 | for f in COLD_FIELDS: |
| 555 | hot_row.setdefault(f, _empty_for(f)) |
| 556 | try: |
| 557 | trace = _row_to_trace(hot_row) |
| 558 | except Exception: |
| 559 | continue |
| 560 | if rid not in traces: |
| 561 | order.append(rid) |
| 562 | traces[rid] = trace |
| 563 | elif rtype == "feedback": |
| 564 | rid = str(row.get("request_id", "")) |
| 565 | t = traces.get(rid) |
| 566 | if t is None: |
| 567 | continue |
| 568 | t.feedback_signal = str(row.get("feedback_signal", "")) |
| 569 | t.feedback_ok = bool(row.get("feedback_ok", False)) |
| 570 | t.feedback_action = str(row.get("feedback_action", "")) |
| 571 | t.feedback_from_tier = str(row.get("feedback_from_tier", "")) |
| 572 | t.feedback_to_tier = str(row.get("feedback_to_tier", "")) |
| 573 | t.feedback_reason = str(row.get("feedback_reason", "")) |
| 574 | t.feedback_submitted_at = float(row.get("feedback_submitted_at", 0.0) or 0.0) |
| 575 | self._records = [traces[rid] for rid in order if rid in traces] |
| 576 | |
| 577 | |
| 578 | def _trace_payload(trace: RequestTrace) -> dict[str, Any]: |
no test coverage detected