From 61b25ab734696e0db583ab4857c1dd69530578c5 Mon Sep 17 00:00:00 2001 From: Floppyrj45 Date: Thu, 19 Feb 2026 14:50:55 +0100 Subject: [PATCH] Fix coverage: remove stray gather code, add /api/coverage route --- .gitignore | 2 ++ app.py.final | 1 + index.html.final | 5 ----- 3 files changed, 3 insertions(+), 5 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..39a3b46 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +db_data/ +db_data/ diff --git a/app.py.final b/app.py.final index 4664c88..7ffaf25 100644 --- a/app.py.final +++ b/app.py.final @@ -1628,6 +1628,7 @@ def real_shots(): return jsonify({'error': 'real_shots.json not found'}), 404 with open(shot_path) as f: return jsonify(json.load(f)) +@app.route("/api/coverage")def get_coverage(): """Get coverage data for all H5 files.""" import re as _re try: darf = {} if os.path.exists(DARF_FILE): with open(DARF_FILE) as _f: darf = json.load(_f) result = [] for f in os.listdir(DATA_DIR): if not f.endswith(".h5"): continue fpath = os.path.join(DATA_DIR, f) info = {"name": f, "size": os.path.getsize(fpath)} m = _re.match(r"auto_(d+)_(d{2})(d{2})(d{2})_b(d+)_rsn(d+)_seq(d+)_(d+)", f) if m: day, hh, mm, ss, board_id, rsn, seq, ts = m.groups() info["board_id"] = int(board_id) info["day"] = int(day) from datetime import datetime as _dt, timedelta as _td base = _dt(2020, 1, 1) + _td(days=int(day)-1, hours=int(hh), minutes=int(mm), seconds=int(ss)) info["date_str"] = base.isoformat() bid_str = str(board_id) if bid_str in darf: info["line"] = darf[bid_str].get("line") info["point"] = darf[bid_str].get("point") info["duration_sec"] = 8000 try: import h5py with h5py.File(fpath, "r") as h5f: attrs = dict(h5f.attrs) info["duration_sec"] = float(attrs.get("duration", attrs.get("record_length", 8000))) except: pass result.append(info) result.sort(key=lambda x: x.get("date_str", "")) return jsonify({"files": result, "count": len(result)}) except Exception as e: return jsonify({"error": str(e)}), 500 if __name__ == '__main__': app.run(host='0.0.0.0', port=3001, debug=False) diff --git a/index.html.final b/index.html.final index f55d337..ae233ff 100644 --- a/index.html.final +++ b/index.html.final @@ -2098,11 +2098,6 @@ async function loadCoverage() { } catch (e) { document.getElementById('coverageEmpty').textContent = 'Error: ' + e.message; } - - // Draw shot time dots on gather - drawShotDots(canvas, ctx, ml, mr, mb, pw, gatherData); - // Shot position overlay - if (gatherData && gatherData.epoch_start) drawGatherShots(canvas, ctx, traces, gatherData.time_axis, parseFloat(document.getElementById("gatherStart").value), parseFloat(document.getElementById("gatherDuration").value), gatherData.epoch_start); } function renderCoverage() {