Implement Purger pattern for scheduling history cleanup
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 17h 7m
- Merged PRs (30d)
- 358
Description
## Overview
Add `Purger` class similar to `Querier` for delete operations on scheduling history tables.
## Background
Currently, scheduling history tables only have record and search operations. As history data accumulates over time, we need cleanup capabilities.
## Requirements
### Purger Class
```python
@dataclass
class Purger:
conditions: list[Condition]
```
### Repository Methods
- `purge_session_history(purger: Purger) -> int`
- `purge_kernel_history(purger: Purger) -> int`
- `purge_deployment_history(purger: Purger) -> int`
- `purge_route_history(purger: Purger) -> int`
### Condition Examples
- By entity ID (session_id, kernel_id, etc.)
- By date (created_before, created_after)
## Usage Example
```python
# Purge by entity
purger = Purger(conditions=[SessionHistoryConditions.by_session_id(session_id)])
deleted_count = await repo.purge_session_history(purger)
# Bulk purge old records
purger = Purger(conditions=[SessionHistoryConditions.created_before(cutoff_date)])
deleted_count = await repo.purge_session_history(purger)
```
## Parent Epic
BA-3060
JIRA Issue: BA-3337
Contributor guide
Assessment
This issue has not been assessed yet.