Refactor bot and integrate services
This commit is contained in:
22
services/artifacts.py
Normal file
22
services/artifacts.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import json
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def artifact_last(state_file: str) -> str:
|
||||
data = json.loads(Path(state_file).read_text())
|
||||
items = sorted(
|
||||
data.items(),
|
||||
key=lambda x: x[1]["updated_at"],
|
||||
reverse=True
|
||||
)
|
||||
name, info = items[0]
|
||||
t = datetime.fromisoformat(info["updated_at"])
|
||||
age_h = int((datetime.now() - t).total_seconds() / 3600)
|
||||
|
||||
return (
|
||||
"🧉 Last artifact\n\n"
|
||||
f"{name}\n"
|
||||
f"Updated: {t:%Y-%m-%d %H:%M}\n"
|
||||
f"Age: {age_h}h"
|
||||
)
|
||||
Reference in New Issue
Block a user