23 lines
552 B
Python
23 lines
552 B
Python
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"
|
|
)
|