Update an existing request log row.
(self, log_id: int, **kwargs)
| 1515 | return cursor.lastrowid |
| 1516 | |
| 1517 | async def update_request_log(self, log_id: int, **kwargs): |
| 1518 | """Update an existing request log row.""" |
| 1519 | if not kwargs: |
| 1520 | return |
| 1521 | |
| 1522 | allowed_fields = { |
| 1523 | "token_id", |
| 1524 | "operation", |
| 1525 | "request_body", |
| 1526 | "response_body", |
| 1527 | "status_code", |
| 1528 | "duration", |
| 1529 | "status_text", |
| 1530 | "progress", |
| 1531 | } |
| 1532 | update_fields = {key: value for key, value in kwargs.items() if key in allowed_fields} |
| 1533 | if not update_fields: |
| 1534 | return |
| 1535 | |
| 1536 | clauses = [] |
| 1537 | values = [] |
| 1538 | for key, value in update_fields.items(): |
| 1539 | clauses.append(f"{key} = ?") |
| 1540 | values.append(value) |
| 1541 | clauses.append("updated_at = CURRENT_TIMESTAMP") |
| 1542 | values.append(log_id) |
| 1543 | |
| 1544 | async with self._connect(write=True) as db: |
| 1545 | await db.execute( |
| 1546 | f"UPDATE request_logs SET {', '.join(clauses)} WHERE id = ?", |
| 1547 | values, |
| 1548 | ) |
| 1549 | await db.commit() |
| 1550 | |
| 1551 | async def get_logs(self, limit: int = 100, token_id: Optional[int] = None, include_payload: bool = False): |
| 1552 | """Get request logs with token info, optionally including payload fields""" |
no test coverage detected