feat: consumption log top1 + elapsed since recording; RTSP play once
- Add top1_name/top1_conf to TSV and show top1–3 in pending markdown - Add 相对开录 column and pass since_recording_start from surgery start - Track surgery_started_wall and format_elapsed_mmss_since in session registry - Remove ffmpeg stream_loop from synthetic/demo fake RTSP (play once) - Fix fake_rtsp_from_file poll loop indentation; update README - Extend consumption TSV tests; add face test PNGs under tests/faces Made-with: Cursor
This commit is contained in:
BIN
tests/faces/图片_20260424165952_58_52.png
Normal file
BIN
tests/faces/图片_20260424165952_58_52.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 388 KiB |
BIN
tests/faces/图片_20260424170014_59_52.png
Normal file
BIN
tests/faces/图片_20260424170014_59_52.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 454 KiB |
BIN
tests/faces/图片_20260424170052_60_52.png
Normal file
BIN
tests/faces/图片_20260424170052_60_52.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 296 KiB |
BIN
tests/faces/图片_20260424170106_61_52.png
Normal file
BIN
tests/faces/图片_20260424170106_61_52.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 283 KiB |
BIN
tests/faces/图片_20260424170114_62_52.png
Normal file
BIN
tests/faces/图片_20260424170114_62_52.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 524 KiB |
@@ -11,6 +11,7 @@ from app.services.consumption_tsv_log import (
|
||||
append_consumption_log_summary,
|
||||
append_consumption_tsv_line,
|
||||
build_consumption_markdown,
|
||||
build_pending_consumption_markdown,
|
||||
build_tsv_line,
|
||||
init_consumption_log_file,
|
||||
replace_pending_line_with_voice_resolution,
|
||||
@@ -48,7 +49,7 @@ def test_build_tsv_line_matches_sample_shape(monkeypatch: pytest.MonkeyPatch) ->
|
||||
wall_end_epoch=w0 + 45.0,
|
||||
)
|
||||
parts = line.rstrip("\n").split("\t")
|
||||
assert len(parts) == 9
|
||||
assert len(parts) == 11
|
||||
assert parts[0] == "2237844"
|
||||
assert parts[1] == "一次性医用灭菌棉签"
|
||||
assert parts[2] == "1"
|
||||
@@ -59,10 +60,12 @@ def test_build_tsv_line_matches_sample_shape(monkeypatch: pytest.MonkeyPatch) ->
|
||||
+ _RANGE_SEP
|
||||
+ "2024-01-01T00:00:45.000+00:00"
|
||||
)
|
||||
assert parts[5] == "cls2"
|
||||
assert parts[6] == "0.0003"
|
||||
assert parts[7] == "cls3"
|
||||
assert parts[8] == "0.0002"
|
||||
assert parts[5] == "一次性医用灭菌棉签"
|
||||
assert parts[6] == "0.9997"
|
||||
assert parts[7] == "cls2"
|
||||
assert parts[8] == "0.0003"
|
||||
assert parts[9] == "cls3"
|
||||
assert parts[10] == "0.0002"
|
||||
|
||||
|
||||
def test_resolve_consumption_item_id_uses_normalized_catalog_key() -> None:
|
||||
@@ -78,6 +81,8 @@ def test_header_columns() -> None:
|
||||
"qty",
|
||||
"doctor_id",
|
||||
"timestamp",
|
||||
"top1_name",
|
||||
"top1_conf",
|
||||
"top2_name",
|
||||
"top2_conf",
|
||||
"top3_name",
|
||||
@@ -101,7 +106,8 @@ def test_replace_pending_line_with_voice_resolution_rewrites_one_row(
|
||||
pending = (
|
||||
"pending:abc-123\t待确认\t1\tvision\t"
|
||||
"cam01@2024-01-01T00:00:00.000+00:00"
|
||||
f"{_RANGE_SEP}2024-01-01T00:00:45.000+00:00\tx\t0.1\ty\t0.2\n"
|
||||
f"{_RANGE_SEP}2024-01-01T00:00:45.000+00:00\t"
|
||||
"一次性针头\t0.5000\tx\t0.1\ty\t0.2\n"
|
||||
)
|
||||
append_consumption_tsv_line("SURG01", pending)
|
||||
replace_pending_line_with_voice_resolution(
|
||||
@@ -189,6 +195,7 @@ def test_build_consumption_markdown_top123_columns(monkeypatch: pytest.MonkeyPat
|
||||
wall_end_epoch=w0 + 45.0,
|
||||
)
|
||||
assert "| item_id |" in md and "| item_name |" in md and "| qty |" in md
|
||||
assert "| 相对开录 |" in md
|
||||
assert "| top2 |" in md and "| top3 |" in md
|
||||
assert "2237844" in md
|
||||
assert "一次性医用灭菌棉签" in md
|
||||
@@ -199,3 +206,33 @@ def test_build_consumption_markdown_top123_columns(monkeypatch: pytest.MonkeyPat
|
||||
assert "2024-01-01 00:00:00.000" in md and "2024-01-01 00:00:45.000" in md
|
||||
assert "cam01" in md and " · " in md and _RANGE_SEP in md
|
||||
assert "cam01@2024-01" not in md
|
||||
assert "| DOCTOR_PLACEHOLDER | — |" in md
|
||||
|
||||
|
||||
def test_build_pending_consumption_markdown_top123(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(bp, "CONSUMPTION_LOG_TIMEZONE", "UTC")
|
||||
snap = ClsTop3(
|
||||
t1_name="输液器A",
|
||||
t1_conf=0.88,
|
||||
t2_name="候选二",
|
||||
t2_conf=0.07,
|
||||
t3_name="候选三",
|
||||
t3_conf=0.02,
|
||||
t1_pid="",
|
||||
t2_pid="",
|
||||
t3_pid="",
|
||||
)
|
||||
w0 = 1704067200.0
|
||||
md = build_pending_consumption_markdown(
|
||||
confirmation_id="cid-1",
|
||||
model_snap=snap,
|
||||
doctor_id="vision",
|
||||
camera_id="or-cam-01",
|
||||
wall_start_epoch=w0,
|
||||
wall_end_epoch=w0 + 15.0,
|
||||
since_recording_start="0分15秒",
|
||||
)
|
||||
assert "| top1 | top2 | top3 |" in md
|
||||
assert "输液器A (0.8800)" in md
|
||||
assert "候选二 (0.0700)" in md
|
||||
assert "候选三 (0.0200)" in md
|
||||
|
||||
Reference in New Issue
Block a user