Would anyone be interested in a -r mode to select runs to remove based on time ranges relative to datetime.now() ?
I could just cleanup the db with sql directly for my use case, but if that feature is wanted by more people, I would implement it if thats okay.
The usage I would propose would be sth like this:
robotdashboard -r 'time=10d' # removes runs older than 10 days
robotdashboard -r 'time=-10d' # removes runs YOUNGER than 10 days
robotdashboard -r 'time=4h' # removes runs older than 4 hours
robotdashboard -r 'time=1y' # removes runs older than 1 year
# maybe there is a better time-reverse indicator than the "-", its a bit ambiguous
Heres a quick example (without time unit specifiers for now, hardcoded to days, now time-reverse logic etc.) of roughly how I would implement it.
Code
def _remove_older_than(self, run: str, run_starts: list):
console = ""
days = int(run.replace("older=", ""))
now = datetime.now(timezone.utc)
cutoff = now-timedelta(days=days)
targets = []
for r in run_starts:
try:
run_dt = datetime.fromisoformat(r)
if run_dt.tzinfo is None:
run_dt = run_dt.replace(tzinfo=timezone.utc)
if run_dt < cutoff:
targets.append(r)
except ValueError:
print(f"Skipping invalid timestamp: {r}")
if not targets:
console += f" INFO: no runs older than {days} days found"
return console
for run_to_remove in targets:
self._remove_run(run_to_remove)
console += f" Removed run: {run_to_remove}"
return console
Would anyone be interested in this feature?
Any notes/tips/recommendations/wishes/critiques on my proposed usage?
Thank you!
Would anyone be interested in a -r mode to select runs to remove based on time ranges relative to datetime.now() ?
I could just cleanup the db with sql directly for my use case, but if that feature is wanted by more people, I would implement it if thats okay.
The usage I would propose would be sth like this:
Heres a quick example (without time unit specifiers for now, hardcoded to days, now time-reverse logic etc.) of roughly how I would implement it.
Code
Would anyone be interested in this feature?
Any notes/tips/recommendations/wishes/critiques on my proposed usage?
Thank you!