Add Gitea CI workflow; fix ruff lint issues
CI / test (push) Successful in 1m16s

This commit is contained in:
2026-06-28 07:44:04 -05:00
parent 129b1eff04
commit bd171d2384
10 changed files with 64 additions and 36 deletions
+20 -20
View File
@@ -35,7 +35,7 @@ def _safe_next(default_url):
def _filter_compatible(query, battery_size):
"""Restrict a Battery query to size-compatible batteries (matching size or unsized)."""
if battery_size:
query = query.filter((Battery.size == battery_size) | (Battery.size == None))
query = query.filter((Battery.size == battery_size) | (Battery.size == None)) # noqa: E711
return query
@@ -130,7 +130,7 @@ def create_app(config_object="config"):
avail_count = sum(1 for b in batteries if b.status == "available")
installed_count = sum(1 for b in batteries if b.status == "installed")
retired_count = sum(1 for b in batteries if b.status == "retired")
devices = db.query(Device).filter(Device.parent_id == None).all()
devices = db.query(Device).filter(Device.parent_id == None).all() # noqa: E711
total_devices = len(devices)
full_devices = sum(
1 for d in devices
@@ -283,16 +283,16 @@ def create_app(config_object="config"):
.order_by(BatteryPctLog.recorded_at.desc())
.all())
charge_logs_data = [
{"id": l.id, "date": l.charged_date, "cycles": l.increment_cycles, "notes": l.notes or ""}
for l in charge_logs
{"id": log.id, "date": log.charged_date, "cycles": log.increment_cycles, "notes": log.notes or ""}
for log in charge_logs
]
capacity_tests_data = [
{"id": t.id, "date": t.tested_date, "mah": t.tested_capacity_mah, "notes": t.notes or ""}
for t in sorted(capacity_tests, key=lambda t: (t.tested_date, t.id), reverse=True)
]
pct_logs_data = [
{"recorded_at": str(l.recorded_at), "pct": l.percentage, "source": l.source or ""}
for l in pct_logs
{"recorded_at": str(log.recorded_at), "pct": log.percentage, "source": log.source or ""}
for log in pct_logs
]
return render_template("battery_detail.html", battery=battery,
storage_locations=storage_locations,
@@ -699,7 +699,7 @@ def create_app(config_object="config"):
@app.route("/device/")
def device_list():
devices = db.query(Device).filter(Device.parent_id == None).order_by(Device.name).all()
devices = db.query(Device).filter(Device.parent_id == None).order_by(Device.name).all() # noqa: E711
device_types = sorted({d.device_type for d in devices if d.device_type})
device_locations = sorted({d.location for d in devices if d.location})
device_battery_sizes = sorted({d.battery_size for d in devices if d.battery_size})
@@ -1237,9 +1237,9 @@ def create_app(config_object="config"):
buf = io.StringIO()
w = csv.writer(buf)
w.writerow(["id", "battery_id", "battery_label", "charged_date", "increment_cycles", "notes"])
for l in rows:
w.writerow([l.id, l.battery_id, l.battery.label,
l.charged_date, l.increment_cycles, l.notes or ""])
for row in rows:
w.writerow([row.id, row.battery_id, row.battery.label,
row.charged_date, row.increment_cycles, row.notes or ""])
return buf.getvalue()
def _capacity_tests_csv():
@@ -1257,9 +1257,9 @@ def create_app(config_object="config"):
buf = io.StringIO()
w = csv.writer(buf)
w.writerow(["id", "battery_id", "battery_label", "percentage", "recorded_at", "source"])
for l in rows:
w.writerow([l.id, l.battery_id, l.battery.label,
l.percentage, l.recorded_at, l.source or ""])
for row in rows:
w.writerow([row.id, row.battery_id, row.battery.label,
row.percentage, row.recorded_at, row.source or ""])
return buf.getvalue()
@app.route("/export")
@@ -1334,10 +1334,10 @@ def create_app(config_object="config"):
for d in devices
],
"charge_logs": [
{"id": l.id, "battery_id": l.battery_id, "battery_label": l.battery.label,
"charged_date": l.charged_date, "increment_cycles": l.increment_cycles,
"notes": l.notes}
for l in charge_logs
{"id": log.id, "battery_id": log.battery_id, "battery_label": log.battery.label,
"charged_date": log.charged_date, "increment_cycles": log.increment_cycles,
"notes": log.notes}
for log in charge_logs
],
"capacity_tests": [
{"id": t.id, "battery_id": t.battery_id, "battery_label": t.battery.label,
@@ -1346,9 +1346,9 @@ def create_app(config_object="config"):
for t in capacity_tests
],
"pct_logs": [
{"id": l.id, "battery_id": l.battery_id, "battery_label": l.battery.label,
"percentage": l.percentage, "recorded_at": l.recorded_at, "source": l.source}
for l in pct_logs
{"id": log.id, "battery_id": log.battery_id, "battery_label": log.battery.label,
"percentage": log.percentage, "recorded_at": log.recorded_at, "source": log.source}
for log in pct_logs
],
}
return Response(json.dumps(payload, indent=2), mimetype="application/json",