Spaces:
Sleeping
Sleeping
Commit ·
c4b2cd0
1
Parent(s): 5884108
feat(ui): add advanced filters (validator/status/date)
Browse files- README.md +1 -0
- src/ui/app_factory.py +280 -24
- tests/unit/test_app_factory_audio_helpers.py +87 -4
README.md
CHANGED
|
@@ -61,3 +61,4 @@ Estrutura base criada por projeto/dataset:
|
|
| 61 |
- Sprint 3 (UX conflito+++): filtro rapido "mostrar apenas conflitos" integrado em refresh, paginacao e acoes de validacao
|
| 62 |
- Sprint 3 (UX conflito++++): atalhos teclado para validacao rapida (1=positivo 2=negativo 3=indeterminado 4=pular R=reaplicar)
|
| 63 |
- Sprint 3 (UX conflito+++++): operacoes em lote para aprovar/rejeitar todos os conflitos em uma unica acao
|
|
|
|
|
|
| 61 |
- Sprint 3 (UX conflito+++): filtro rapido "mostrar apenas conflitos" integrado em refresh, paginacao e acoes de validacao
|
| 62 |
- Sprint 3 (UX conflito++++): atalhos teclado para validacao rapida (1=positivo 2=negativo 3=indeterminado 4=pular R=reaplicar)
|
| 63 |
- Sprint 3 (UX conflito+++++): operacoes em lote para aprovar/rejeitar todos os conflitos em uma unica acao
|
| 64 |
+
- Sprint 3 (UX conflito++++++): filtros avancados por validador, status e data de atualizacao em toda a navegacao
|
src/ui/app_factory.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import tempfile
|
|
|
|
| 3 |
from pathlib import Path
|
| 4 |
from typing import Protocol
|
| 5 |
|
|
@@ -102,6 +103,9 @@ def _page_to_table(
|
|
| 102 |
page: int,
|
| 103 |
scientific_name: str,
|
| 104 |
min_confidence: float,
|
|
|
|
|
|
|
|
|
|
| 105 |
conflict_detection_key: str = "",
|
| 106 |
show_conflicts_only: bool = False,
|
| 107 |
):
|
|
@@ -116,6 +120,10 @@ def _page_to_table(
|
|
| 116 |
|
| 117 |
snapshot = snapshot_reader.load_current_snapshot(project_slug=project_slug)
|
| 118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
rows = [
|
| 120 |
[
|
| 121 |
item.detection_key,
|
|
@@ -132,10 +140,39 @@ def _page_to_table(
|
|
| 132 |
for item in page_obj.items
|
| 133 |
]
|
| 134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
if show_conflicts_only:
|
| 136 |
rows = [row for row in rows if str(row[8]) == "CONFLICT"]
|
| 137 |
|
| 138 |
-
status = f"Pagina {page_obj.page}/{page_obj.total_pages} | Total
|
| 139 |
if show_conflicts_only:
|
| 140 |
status = f"{status} | Apenas conflitos: {len(rows)} item(ns)"
|
| 141 |
return rows, status, page_obj.page
|
|
@@ -320,6 +357,9 @@ def _save_selected_validation_with_refresh(
|
|
| 320 |
page: int,
|
| 321 |
scientific_name: str,
|
| 322 |
min_confidence: float,
|
|
|
|
|
|
|
|
|
|
| 323 |
show_conflicts_only: bool,
|
| 324 |
) -> tuple[str, str, str | None, list[list[object]], int, int, str, str]:
|
| 325 |
selected_key = ""
|
|
@@ -347,6 +387,9 @@ def _save_selected_validation_with_refresh(
|
|
| 347 |
page=page,
|
| 348 |
scientific_name=scientific_name,
|
| 349 |
min_confidence=min_confidence,
|
|
|
|
|
|
|
|
|
|
| 350 |
show_conflicts_only=show_conflicts_only,
|
| 351 |
)
|
| 352 |
|
|
@@ -364,6 +407,9 @@ def _save_selected_validation_with_refresh(
|
|
| 364 |
page=refreshed_page,
|
| 365 |
scientific_name=scientific_name,
|
| 366 |
min_confidence=min_confidence,
|
|
|
|
|
|
|
|
|
|
| 367 |
conflict_detection_key=conflict_key,
|
| 368 |
show_conflicts_only=show_conflicts_only,
|
| 369 |
)
|
|
@@ -403,6 +449,9 @@ def _reapply_last_conflict_validation_with_refresh(
|
|
| 403 |
page: int,
|
| 404 |
scientific_name: str,
|
| 405 |
min_confidence: float,
|
|
|
|
|
|
|
|
|
|
| 406 |
show_conflicts_only: bool,
|
| 407 |
) -> tuple[str, str, str | None, list[list[object]], int, int, str, str]:
|
| 408 |
if not pending_status_value:
|
|
@@ -413,6 +462,9 @@ def _reapply_last_conflict_validation_with_refresh(
|
|
| 413 |
page=page,
|
| 414 |
scientific_name=scientific_name,
|
| 415 |
min_confidence=min_confidence,
|
|
|
|
|
|
|
|
|
|
| 416 |
show_conflicts_only=show_conflicts_only,
|
| 417 |
)
|
| 418 |
return (
|
|
@@ -442,6 +494,9 @@ def _reapply_last_conflict_validation_with_refresh(
|
|
| 442 |
page=page,
|
| 443 |
scientific_name=scientific_name,
|
| 444 |
min_confidence=min_confidence,
|
|
|
|
|
|
|
|
|
|
| 445 |
show_conflicts_only=show_conflicts_only,
|
| 446 |
)
|
| 447 |
|
|
@@ -460,6 +515,9 @@ def _batch_validate_conflicts(
|
|
| 460 |
page: int,
|
| 461 |
scientific_name: str,
|
| 462 |
min_confidence: float,
|
|
|
|
|
|
|
|
|
|
| 463 |
) -> tuple[str, str, str | None, list[list[object]], int]:
|
| 464 |
"""Apply the same validation status to all visible conflicts in the table."""
|
| 465 |
validator_name = validator.strip()
|
|
@@ -511,6 +569,9 @@ def _batch_validate_conflicts(
|
|
| 511 |
page=page,
|
| 512 |
scientific_name=scientific_name,
|
| 513 |
min_confidence=min_confidence,
|
|
|
|
|
|
|
|
|
|
| 514 |
show_conflicts_only=False,
|
| 515 |
)
|
| 516 |
|
|
@@ -534,6 +595,9 @@ def _batch_reapply_all_pending(
|
|
| 534 |
page: int,
|
| 535 |
scientific_name: str,
|
| 536 |
min_confidence: float,
|
|
|
|
|
|
|
|
|
|
| 537 |
) -> tuple[str, str, str | None, list[list[object]], int]:
|
| 538 |
"""Reapply all pending validations (stored conflicts) with current version."""
|
| 539 |
if not pending_statuses:
|
|
@@ -576,6 +640,9 @@ def _batch_reapply_all_pending(
|
|
| 576 |
page=page,
|
| 577 |
scientific_name=scientific_name,
|
| 578 |
min_confidence=min_confidence,
|
|
|
|
|
|
|
|
|
|
| 579 |
show_conflicts_only=False,
|
| 580 |
)
|
| 581 |
|
|
@@ -604,6 +671,15 @@ def create_app() -> gr.Blocks:
|
|
| 604 |
min_confidence = gr.Slider(label="Confianca minima", minimum=0.0, maximum=1.0, step=0.01, value=0.0)
|
| 605 |
show_conflicts_only = gr.Checkbox(label="Mostrar apenas conflitos", value=False)
|
| 606 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 607 |
with gr.Row():
|
| 608 |
prev_btn = gr.Button("Pagina anterior")
|
| 609 |
next_btn = gr.Button("Proxima pagina")
|
|
@@ -685,7 +761,15 @@ def create_app() -> gr.Blocks:
|
|
| 685 |
"</script>"
|
| 686 |
)
|
| 687 |
|
| 688 |
-
def refresh(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 689 |
return _page_to_table(
|
| 690 |
service=service,
|
| 691 |
snapshot_reader=validation_repository,
|
|
@@ -693,14 +777,49 @@ def create_app() -> gr.Blocks:
|
|
| 693 |
page=page,
|
| 694 |
scientific_name=species,
|
| 695 |
min_confidence=confidence,
|
|
|
|
|
|
|
|
|
|
| 696 |
show_conflicts_only=only_conflicts,
|
| 697 |
)
|
| 698 |
|
| 699 |
-
def go_next(
|
| 700 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 701 |
|
| 702 |
-
def go_prev(
|
| 703 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 704 |
|
| 705 |
def on_select(evt):
|
| 706 |
if isinstance(evt.index, tuple):
|
|
@@ -711,22 +830,61 @@ def create_app() -> gr.Blocks:
|
|
| 711 |
|
| 712 |
demo.load(
|
| 713 |
fn=refresh,
|
| 714 |
-
inputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 715 |
outputs=[table, status, page_state],
|
| 716 |
)
|
| 717 |
refresh_btn.click(
|
| 718 |
-
fn=lambda species, confidence,
|
| 719 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 720 |
outputs=[table, status, page_state],
|
| 721 |
)
|
| 722 |
next_btn.click(
|
| 723 |
fn=go_next,
|
| 724 |
-
inputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 725 |
outputs=[table, status, page_state],
|
| 726 |
)
|
| 727 |
prev_btn.click(
|
| 728 |
fn=go_prev,
|
| 729 |
-
inputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 730 |
outputs=[table, status, page_state],
|
| 731 |
)
|
| 732 |
table.select(fn=on_select, inputs=None, outputs=[selected_index])
|
|
@@ -747,7 +905,7 @@ def create_app() -> gr.Blocks:
|
|
| 747 |
outputs=[status, audio_player],
|
| 748 |
)
|
| 749 |
approve_btn.click(
|
| 750 |
-
fn=lambda rows, idx, name, notes, cache_key, page, species, confidence, only_conflicts: _save_selected_validation_with_refresh(
|
| 751 |
validation_service=validation_service,
|
| 752 |
audio_service=audio_service,
|
| 753 |
queue_service=service,
|
|
@@ -762,13 +920,29 @@ def create_app() -> gr.Blocks:
|
|
| 762 |
page=int(page),
|
| 763 |
scientific_name=species,
|
| 764 |
min_confidence=float(confidence),
|
|
|
|
|
|
|
|
|
|
| 765 |
show_conflicts_only=bool(only_conflicts),
|
| 766 |
),
|
| 767 |
-
inputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 768 |
outputs=[status, cache_key_state, audio_player, table, page_state, selected_index, pending_status_state, conflict_detection_key_state],
|
| 769 |
)
|
| 770 |
reject_btn.click(
|
| 771 |
-
fn=lambda rows, idx, name, notes, cache_key, page, species, confidence, only_conflicts: _save_selected_validation_with_refresh(
|
| 772 |
validation_service=validation_service,
|
| 773 |
audio_service=audio_service,
|
| 774 |
queue_service=service,
|
|
@@ -783,13 +957,29 @@ def create_app() -> gr.Blocks:
|
|
| 783 |
page=int(page),
|
| 784 |
scientific_name=species,
|
| 785 |
min_confidence=float(confidence),
|
|
|
|
|
|
|
|
|
|
| 786 |
show_conflicts_only=bool(only_conflicts),
|
| 787 |
),
|
| 788 |
-
inputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 789 |
outputs=[status, cache_key_state, audio_player, table, page_state, selected_index, pending_status_state, conflict_detection_key_state],
|
| 790 |
)
|
| 791 |
uncertain_btn.click(
|
| 792 |
-
fn=lambda rows, idx, name, notes, cache_key, page, species, confidence, only_conflicts: _save_selected_validation_with_refresh(
|
| 793 |
validation_service=validation_service,
|
| 794 |
audio_service=audio_service,
|
| 795 |
queue_service=service,
|
|
@@ -804,13 +994,29 @@ def create_app() -> gr.Blocks:
|
|
| 804 |
page=int(page),
|
| 805 |
scientific_name=species,
|
| 806 |
min_confidence=float(confidence),
|
|
|
|
|
|
|
|
|
|
| 807 |
show_conflicts_only=bool(only_conflicts),
|
| 808 |
),
|
| 809 |
-
inputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 810 |
outputs=[status, cache_key_state, audio_player, table, page_state, selected_index, pending_status_state, conflict_detection_key_state],
|
| 811 |
)
|
| 812 |
skip_btn.click(
|
| 813 |
-
fn=lambda rows, idx, name, notes, cache_key, page, species, confidence, only_conflicts: _save_selected_validation_with_refresh(
|
| 814 |
validation_service=validation_service,
|
| 815 |
audio_service=audio_service,
|
| 816 |
queue_service=service,
|
|
@@ -825,13 +1031,29 @@ def create_app() -> gr.Blocks:
|
|
| 825 |
page=int(page),
|
| 826 |
scientific_name=species,
|
| 827 |
min_confidence=float(confidence),
|
|
|
|
|
|
|
|
|
|
| 828 |
show_conflicts_only=bool(only_conflicts),
|
| 829 |
),
|
| 830 |
-
inputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 831 |
outputs=[status, cache_key_state, audio_player, table, page_state, selected_index, pending_status_state, conflict_detection_key_state],
|
| 832 |
)
|
| 833 |
reapply_btn.click(
|
| 834 |
-
fn=lambda rows, idx, pending_status, conflict_key, name, notes, cache_key, page, species, confidence, only_conflicts: _reapply_last_conflict_validation_with_refresh(
|
| 835 |
validation_service=validation_service,
|
| 836 |
audio_service=audio_service,
|
| 837 |
queue_service=service,
|
|
@@ -847,6 +1069,9 @@ def create_app() -> gr.Blocks:
|
|
| 847 |
page=int(page),
|
| 848 |
scientific_name=species,
|
| 849 |
min_confidence=float(confidence),
|
|
|
|
|
|
|
|
|
|
| 850 |
show_conflicts_only=bool(only_conflicts),
|
| 851 |
),
|
| 852 |
inputs=[
|
|
@@ -860,12 +1085,15 @@ def create_app() -> gr.Blocks:
|
|
| 860 |
page_state,
|
| 861 |
species_filter,
|
| 862 |
min_confidence,
|
|
|
|
|
|
|
|
|
|
| 863 |
show_conflicts_only,
|
| 864 |
],
|
| 865 |
outputs=[status, cache_key_state, audio_player, table, page_state, selected_index, pending_status_state, conflict_detection_key_state],
|
| 866 |
)
|
| 867 |
batch_approve_conflicts_btn.click(
|
| 868 |
-
fn=lambda rows, name, notes, cache_key, page, species, confidence: _batch_validate_conflicts(
|
| 869 |
validation_service=validation_service,
|
| 870 |
audio_service=audio_service,
|
| 871 |
queue_service=service,
|
|
@@ -879,12 +1107,26 @@ def create_app() -> gr.Blocks:
|
|
| 879 |
page=int(page),
|
| 880 |
scientific_name=species,
|
| 881 |
min_confidence=float(confidence),
|
|
|
|
|
|
|
|
|
|
| 882 |
),
|
| 883 |
-
inputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 884 |
outputs=[status, cache_key_state, audio_player, table, page_state],
|
| 885 |
)
|
| 886 |
batch_reject_conflicts_btn.click(
|
| 887 |
-
fn=lambda rows, name, notes, cache_key, page, species, confidence: _batch_validate_conflicts(
|
| 888 |
validation_service=validation_service,
|
| 889 |
audio_service=audio_service,
|
| 890 |
queue_service=service,
|
|
@@ -898,8 +1140,22 @@ def create_app() -> gr.Blocks:
|
|
| 898 |
page=int(page),
|
| 899 |
scientific_name=species,
|
| 900 |
min_confidence=float(confidence),
|
|
|
|
|
|
|
|
|
|
| 901 |
),
|
| 902 |
-
inputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 903 |
outputs=[status, cache_key_state, audio_player, table, page_state],
|
| 904 |
)
|
| 905 |
report_btn.click(
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import tempfile
|
| 3 |
+
from datetime import datetime
|
| 4 |
from pathlib import Path
|
| 5 |
from typing import Protocol
|
| 6 |
|
|
|
|
| 103 |
page: int,
|
| 104 |
scientific_name: str,
|
| 105 |
min_confidence: float,
|
| 106 |
+
validator_filter: str = "",
|
| 107 |
+
status_filter: str = "all",
|
| 108 |
+
updated_after: str = "",
|
| 109 |
conflict_detection_key: str = "",
|
| 110 |
show_conflicts_only: bool = False,
|
| 111 |
):
|
|
|
|
| 120 |
|
| 121 |
snapshot = snapshot_reader.load_current_snapshot(project_slug=project_slug)
|
| 122 |
|
| 123 |
+
normalized_status_filter = status_filter.strip().lower() if status_filter else "all"
|
| 124 |
+
normalized_validator_filter = validator_filter.strip().lower()
|
| 125 |
+
updated_after_date = updated_after.strip()
|
| 126 |
+
|
| 127 |
rows = [
|
| 128 |
[
|
| 129 |
item.detection_key,
|
|
|
|
| 140 |
for item in page_obj.items
|
| 141 |
]
|
| 142 |
|
| 143 |
+
if normalized_validator_filter:
|
| 144 |
+
rows = [
|
| 145 |
+
row
|
| 146 |
+
for row in rows
|
| 147 |
+
if normalized_validator_filter in str(snapshot.get(str(row[0]), {}).get("validator", "")).strip().lower()
|
| 148 |
+
]
|
| 149 |
+
|
| 150 |
+
if normalized_status_filter and normalized_status_filter != "all":
|
| 151 |
+
rows = [row for row in rows if str(row[6]).strip().lower() == normalized_status_filter]
|
| 152 |
+
|
| 153 |
+
if updated_after_date:
|
| 154 |
+
try:
|
| 155 |
+
cutoff_date = datetime.strptime(updated_after_date, "%Y-%m-%d").date()
|
| 156 |
+
filtered_rows: list[list[object]] = []
|
| 157 |
+
for row in rows:
|
| 158 |
+
snapshot_item = snapshot.get(str(row[0]), {})
|
| 159 |
+
updated_at_value = str(snapshot_item.get("updated_at", "")).strip()
|
| 160 |
+
if not updated_at_value:
|
| 161 |
+
continue
|
| 162 |
+
try:
|
| 163 |
+
item_date = datetime.fromisoformat(updated_at_value.replace("Z", "+00:00")).date()
|
| 164 |
+
if item_date >= cutoff_date:
|
| 165 |
+
filtered_rows.append(row)
|
| 166 |
+
except ValueError:
|
| 167 |
+
continue
|
| 168 |
+
rows = filtered_rows
|
| 169 |
+
except ValueError:
|
| 170 |
+
pass
|
| 171 |
+
|
| 172 |
if show_conflicts_only:
|
| 173 |
rows = [row for row in rows if str(row[8]) == "CONFLICT"]
|
| 174 |
|
| 175 |
+
status = f"Pagina {page_obj.page}/{page_obj.total_pages} | Total base: {page_obj.total_items} | Exibidos: {len(rows)}"
|
| 176 |
if show_conflicts_only:
|
| 177 |
status = f"{status} | Apenas conflitos: {len(rows)} item(ns)"
|
| 178 |
return rows, status, page_obj.page
|
|
|
|
| 357 |
page: int,
|
| 358 |
scientific_name: str,
|
| 359 |
min_confidence: float,
|
| 360 |
+
validator_filter: str,
|
| 361 |
+
status_filter: str,
|
| 362 |
+
updated_after: str,
|
| 363 |
show_conflicts_only: bool,
|
| 364 |
) -> tuple[str, str, str | None, list[list[object]], int, int, str, str]:
|
| 365 |
selected_key = ""
|
|
|
|
| 387 |
page=page,
|
| 388 |
scientific_name=scientific_name,
|
| 389 |
min_confidence=min_confidence,
|
| 390 |
+
validator_filter=validator_filter,
|
| 391 |
+
status_filter=status_filter,
|
| 392 |
+
updated_after=updated_after,
|
| 393 |
show_conflicts_only=show_conflicts_only,
|
| 394 |
)
|
| 395 |
|
|
|
|
| 407 |
page=refreshed_page,
|
| 408 |
scientific_name=scientific_name,
|
| 409 |
min_confidence=min_confidence,
|
| 410 |
+
validator_filter=validator_filter,
|
| 411 |
+
status_filter=status_filter,
|
| 412 |
+
updated_after=updated_after,
|
| 413 |
conflict_detection_key=conflict_key,
|
| 414 |
show_conflicts_only=show_conflicts_only,
|
| 415 |
)
|
|
|
|
| 449 |
page: int,
|
| 450 |
scientific_name: str,
|
| 451 |
min_confidence: float,
|
| 452 |
+
validator_filter: str,
|
| 453 |
+
status_filter: str,
|
| 454 |
+
updated_after: str,
|
| 455 |
show_conflicts_only: bool,
|
| 456 |
) -> tuple[str, str, str | None, list[list[object]], int, int, str, str]:
|
| 457 |
if not pending_status_value:
|
|
|
|
| 462 |
page=page,
|
| 463 |
scientific_name=scientific_name,
|
| 464 |
min_confidence=min_confidence,
|
| 465 |
+
validator_filter=validator_filter,
|
| 466 |
+
status_filter=status_filter,
|
| 467 |
+
updated_after=updated_after,
|
| 468 |
show_conflicts_only=show_conflicts_only,
|
| 469 |
)
|
| 470 |
return (
|
|
|
|
| 494 |
page=page,
|
| 495 |
scientific_name=scientific_name,
|
| 496 |
min_confidence=min_confidence,
|
| 497 |
+
validator_filter=validator_filter,
|
| 498 |
+
status_filter=status_filter,
|
| 499 |
+
updated_after=updated_after,
|
| 500 |
show_conflicts_only=show_conflicts_only,
|
| 501 |
)
|
| 502 |
|
|
|
|
| 515 |
page: int,
|
| 516 |
scientific_name: str,
|
| 517 |
min_confidence: float,
|
| 518 |
+
validator_filter: str,
|
| 519 |
+
status_filter: str,
|
| 520 |
+
updated_after: str,
|
| 521 |
) -> tuple[str, str, str | None, list[list[object]], int]:
|
| 522 |
"""Apply the same validation status to all visible conflicts in the table."""
|
| 523 |
validator_name = validator.strip()
|
|
|
|
| 569 |
page=page,
|
| 570 |
scientific_name=scientific_name,
|
| 571 |
min_confidence=min_confidence,
|
| 572 |
+
validator_filter=validator_filter,
|
| 573 |
+
status_filter=status_filter,
|
| 574 |
+
updated_after=updated_after,
|
| 575 |
show_conflicts_only=False,
|
| 576 |
)
|
| 577 |
|
|
|
|
| 595 |
page: int,
|
| 596 |
scientific_name: str,
|
| 597 |
min_confidence: float,
|
| 598 |
+
validator_filter: str,
|
| 599 |
+
status_filter: str,
|
| 600 |
+
updated_after: str,
|
| 601 |
) -> tuple[str, str, str | None, list[list[object]], int]:
|
| 602 |
"""Reapply all pending validations (stored conflicts) with current version."""
|
| 603 |
if not pending_statuses:
|
|
|
|
| 640 |
page=page,
|
| 641 |
scientific_name=scientific_name,
|
| 642 |
min_confidence=min_confidence,
|
| 643 |
+
validator_filter=validator_filter,
|
| 644 |
+
status_filter=status_filter,
|
| 645 |
+
updated_after=updated_after,
|
| 646 |
show_conflicts_only=False,
|
| 647 |
)
|
| 648 |
|
|
|
|
| 671 |
min_confidence = gr.Slider(label="Confianca minima", minimum=0.0, maximum=1.0, step=0.01, value=0.0)
|
| 672 |
show_conflicts_only = gr.Checkbox(label="Mostrar apenas conflitos", value=False)
|
| 673 |
|
| 674 |
+
with gr.Row():
|
| 675 |
+
validator_filter = gr.Textbox(label="Filtro validador", placeholder="Ex: validator-demo")
|
| 676 |
+
validation_status_filter = gr.Dropdown(
|
| 677 |
+
label="Filtro status",
|
| 678 |
+
choices=["all", "pending", "positive", "negative", "uncertain", "skip"],
|
| 679 |
+
value="all",
|
| 680 |
+
)
|
| 681 |
+
updated_after_filter = gr.Textbox(label="Atualizado a partir de (YYYY-MM-DD)", placeholder="Ex: 2026-03-25")
|
| 682 |
+
|
| 683 |
with gr.Row():
|
| 684 |
prev_btn = gr.Button("Pagina anterior")
|
| 685 |
next_btn = gr.Button("Proxima pagina")
|
|
|
|
| 761 |
"</script>"
|
| 762 |
)
|
| 763 |
|
| 764 |
+
def refresh(
|
| 765 |
+
page: int,
|
| 766 |
+
species: str,
|
| 767 |
+
confidence: float,
|
| 768 |
+
validator_filter_value: str,
|
| 769 |
+
status_filter_value: str,
|
| 770 |
+
updated_after_value: str,
|
| 771 |
+
only_conflicts: bool,
|
| 772 |
+
):
|
| 773 |
return _page_to_table(
|
| 774 |
service=service,
|
| 775 |
snapshot_reader=validation_repository,
|
|
|
|
| 777 |
page=page,
|
| 778 |
scientific_name=species,
|
| 779 |
min_confidence=confidence,
|
| 780 |
+
validator_filter=validator_filter_value,
|
| 781 |
+
status_filter=status_filter_value,
|
| 782 |
+
updated_after=updated_after_value,
|
| 783 |
show_conflicts_only=only_conflicts,
|
| 784 |
)
|
| 785 |
|
| 786 |
+
def go_next(
|
| 787 |
+
page: int,
|
| 788 |
+
species: str,
|
| 789 |
+
confidence: float,
|
| 790 |
+
validator_filter_value: str,
|
| 791 |
+
status_filter_value: str,
|
| 792 |
+
updated_after_value: str,
|
| 793 |
+
only_conflicts: bool,
|
| 794 |
+
):
|
| 795 |
+
return refresh(
|
| 796 |
+
page + 1,
|
| 797 |
+
species,
|
| 798 |
+
confidence,
|
| 799 |
+
validator_filter_value,
|
| 800 |
+
status_filter_value,
|
| 801 |
+
updated_after_value,
|
| 802 |
+
only_conflicts,
|
| 803 |
+
)
|
| 804 |
|
| 805 |
+
def go_prev(
|
| 806 |
+
page: int,
|
| 807 |
+
species: str,
|
| 808 |
+
confidence: float,
|
| 809 |
+
validator_filter_value: str,
|
| 810 |
+
status_filter_value: str,
|
| 811 |
+
updated_after_value: str,
|
| 812 |
+
only_conflicts: bool,
|
| 813 |
+
):
|
| 814 |
+
return refresh(
|
| 815 |
+
max(1, page - 1),
|
| 816 |
+
species,
|
| 817 |
+
confidence,
|
| 818 |
+
validator_filter_value,
|
| 819 |
+
status_filter_value,
|
| 820 |
+
updated_after_value,
|
| 821 |
+
only_conflicts,
|
| 822 |
+
)
|
| 823 |
|
| 824 |
def on_select(evt):
|
| 825 |
if isinstance(evt.index, tuple):
|
|
|
|
| 830 |
|
| 831 |
demo.load(
|
| 832 |
fn=refresh,
|
| 833 |
+
inputs=[
|
| 834 |
+
page_state,
|
| 835 |
+
species_filter,
|
| 836 |
+
min_confidence,
|
| 837 |
+
validator_filter,
|
| 838 |
+
validation_status_filter,
|
| 839 |
+
updated_after_filter,
|
| 840 |
+
show_conflicts_only,
|
| 841 |
+
],
|
| 842 |
outputs=[table, status, page_state],
|
| 843 |
)
|
| 844 |
refresh_btn.click(
|
| 845 |
+
fn=lambda species, confidence, validator_filter_value, status_filter_value, updated_after_value, only_conflicts: refresh(
|
| 846 |
+
1,
|
| 847 |
+
species,
|
| 848 |
+
confidence,
|
| 849 |
+
validator_filter_value,
|
| 850 |
+
status_filter_value,
|
| 851 |
+
updated_after_value,
|
| 852 |
+
only_conflicts,
|
| 853 |
+
),
|
| 854 |
+
inputs=[
|
| 855 |
+
species_filter,
|
| 856 |
+
min_confidence,
|
| 857 |
+
validator_filter,
|
| 858 |
+
validation_status_filter,
|
| 859 |
+
updated_after_filter,
|
| 860 |
+
show_conflicts_only,
|
| 861 |
+
],
|
| 862 |
outputs=[table, status, page_state],
|
| 863 |
)
|
| 864 |
next_btn.click(
|
| 865 |
fn=go_next,
|
| 866 |
+
inputs=[
|
| 867 |
+
page_state,
|
| 868 |
+
species_filter,
|
| 869 |
+
min_confidence,
|
| 870 |
+
validator_filter,
|
| 871 |
+
validation_status_filter,
|
| 872 |
+
updated_after_filter,
|
| 873 |
+
show_conflicts_only,
|
| 874 |
+
],
|
| 875 |
outputs=[table, status, page_state],
|
| 876 |
)
|
| 877 |
prev_btn.click(
|
| 878 |
fn=go_prev,
|
| 879 |
+
inputs=[
|
| 880 |
+
page_state,
|
| 881 |
+
species_filter,
|
| 882 |
+
min_confidence,
|
| 883 |
+
validator_filter,
|
| 884 |
+
validation_status_filter,
|
| 885 |
+
updated_after_filter,
|
| 886 |
+
show_conflicts_only,
|
| 887 |
+
],
|
| 888 |
outputs=[table, status, page_state],
|
| 889 |
)
|
| 890 |
table.select(fn=on_select, inputs=None, outputs=[selected_index])
|
|
|
|
| 905 |
outputs=[status, audio_player],
|
| 906 |
)
|
| 907 |
approve_btn.click(
|
| 908 |
+
fn=lambda rows, idx, name, notes, cache_key, page, species, confidence, validator_filter_value, status_filter_value, updated_after_value, only_conflicts: _save_selected_validation_with_refresh(
|
| 909 |
validation_service=validation_service,
|
| 910 |
audio_service=audio_service,
|
| 911 |
queue_service=service,
|
|
|
|
| 920 |
page=int(page),
|
| 921 |
scientific_name=species,
|
| 922 |
min_confidence=float(confidence),
|
| 923 |
+
validator_filter=validator_filter_value,
|
| 924 |
+
status_filter=status_filter_value,
|
| 925 |
+
updated_after=updated_after_value,
|
| 926 |
show_conflicts_only=bool(only_conflicts),
|
| 927 |
),
|
| 928 |
+
inputs=[
|
| 929 |
+
table,
|
| 930 |
+
selected_index,
|
| 931 |
+
validator_name,
|
| 932 |
+
validation_notes,
|
| 933 |
+
cache_key_state,
|
| 934 |
+
page_state,
|
| 935 |
+
species_filter,
|
| 936 |
+
min_confidence,
|
| 937 |
+
validator_filter,
|
| 938 |
+
validation_status_filter,
|
| 939 |
+
updated_after_filter,
|
| 940 |
+
show_conflicts_only,
|
| 941 |
+
],
|
| 942 |
outputs=[status, cache_key_state, audio_player, table, page_state, selected_index, pending_status_state, conflict_detection_key_state],
|
| 943 |
)
|
| 944 |
reject_btn.click(
|
| 945 |
+
fn=lambda rows, idx, name, notes, cache_key, page, species, confidence, validator_filter_value, status_filter_value, updated_after_value, only_conflicts: _save_selected_validation_with_refresh(
|
| 946 |
validation_service=validation_service,
|
| 947 |
audio_service=audio_service,
|
| 948 |
queue_service=service,
|
|
|
|
| 957 |
page=int(page),
|
| 958 |
scientific_name=species,
|
| 959 |
min_confidence=float(confidence),
|
| 960 |
+
validator_filter=validator_filter_value,
|
| 961 |
+
status_filter=status_filter_value,
|
| 962 |
+
updated_after=updated_after_value,
|
| 963 |
show_conflicts_only=bool(only_conflicts),
|
| 964 |
),
|
| 965 |
+
inputs=[
|
| 966 |
+
table,
|
| 967 |
+
selected_index,
|
| 968 |
+
validator_name,
|
| 969 |
+
validation_notes,
|
| 970 |
+
cache_key_state,
|
| 971 |
+
page_state,
|
| 972 |
+
species_filter,
|
| 973 |
+
min_confidence,
|
| 974 |
+
validator_filter,
|
| 975 |
+
validation_status_filter,
|
| 976 |
+
updated_after_filter,
|
| 977 |
+
show_conflicts_only,
|
| 978 |
+
],
|
| 979 |
outputs=[status, cache_key_state, audio_player, table, page_state, selected_index, pending_status_state, conflict_detection_key_state],
|
| 980 |
)
|
| 981 |
uncertain_btn.click(
|
| 982 |
+
fn=lambda rows, idx, name, notes, cache_key, page, species, confidence, validator_filter_value, status_filter_value, updated_after_value, only_conflicts: _save_selected_validation_with_refresh(
|
| 983 |
validation_service=validation_service,
|
| 984 |
audio_service=audio_service,
|
| 985 |
queue_service=service,
|
|
|
|
| 994 |
page=int(page),
|
| 995 |
scientific_name=species,
|
| 996 |
min_confidence=float(confidence),
|
| 997 |
+
validator_filter=validator_filter_value,
|
| 998 |
+
status_filter=status_filter_value,
|
| 999 |
+
updated_after=updated_after_value,
|
| 1000 |
show_conflicts_only=bool(only_conflicts),
|
| 1001 |
),
|
| 1002 |
+
inputs=[
|
| 1003 |
+
table,
|
| 1004 |
+
selected_index,
|
| 1005 |
+
validator_name,
|
| 1006 |
+
validation_notes,
|
| 1007 |
+
cache_key_state,
|
| 1008 |
+
page_state,
|
| 1009 |
+
species_filter,
|
| 1010 |
+
min_confidence,
|
| 1011 |
+
validator_filter,
|
| 1012 |
+
validation_status_filter,
|
| 1013 |
+
updated_after_filter,
|
| 1014 |
+
show_conflicts_only,
|
| 1015 |
+
],
|
| 1016 |
outputs=[status, cache_key_state, audio_player, table, page_state, selected_index, pending_status_state, conflict_detection_key_state],
|
| 1017 |
)
|
| 1018 |
skip_btn.click(
|
| 1019 |
+
fn=lambda rows, idx, name, notes, cache_key, page, species, confidence, validator_filter_value, status_filter_value, updated_after_value, only_conflicts: _save_selected_validation_with_refresh(
|
| 1020 |
validation_service=validation_service,
|
| 1021 |
audio_service=audio_service,
|
| 1022 |
queue_service=service,
|
|
|
|
| 1031 |
page=int(page),
|
| 1032 |
scientific_name=species,
|
| 1033 |
min_confidence=float(confidence),
|
| 1034 |
+
validator_filter=validator_filter_value,
|
| 1035 |
+
status_filter=status_filter_value,
|
| 1036 |
+
updated_after=updated_after_value,
|
| 1037 |
show_conflicts_only=bool(only_conflicts),
|
| 1038 |
),
|
| 1039 |
+
inputs=[
|
| 1040 |
+
table,
|
| 1041 |
+
selected_index,
|
| 1042 |
+
validator_name,
|
| 1043 |
+
validation_notes,
|
| 1044 |
+
cache_key_state,
|
| 1045 |
+
page_state,
|
| 1046 |
+
species_filter,
|
| 1047 |
+
min_confidence,
|
| 1048 |
+
validator_filter,
|
| 1049 |
+
validation_status_filter,
|
| 1050 |
+
updated_after_filter,
|
| 1051 |
+
show_conflicts_only,
|
| 1052 |
+
],
|
| 1053 |
outputs=[status, cache_key_state, audio_player, table, page_state, selected_index, pending_status_state, conflict_detection_key_state],
|
| 1054 |
)
|
| 1055 |
reapply_btn.click(
|
| 1056 |
+
fn=lambda rows, idx, pending_status, conflict_key, name, notes, cache_key, page, species, confidence, validator_filter_value, status_filter_value, updated_after_value, only_conflicts: _reapply_last_conflict_validation_with_refresh(
|
| 1057 |
validation_service=validation_service,
|
| 1058 |
audio_service=audio_service,
|
| 1059 |
queue_service=service,
|
|
|
|
| 1069 |
page=int(page),
|
| 1070 |
scientific_name=species,
|
| 1071 |
min_confidence=float(confidence),
|
| 1072 |
+
validator_filter=validator_filter_value,
|
| 1073 |
+
status_filter=status_filter_value,
|
| 1074 |
+
updated_after=updated_after_value,
|
| 1075 |
show_conflicts_only=bool(only_conflicts),
|
| 1076 |
),
|
| 1077 |
inputs=[
|
|
|
|
| 1085 |
page_state,
|
| 1086 |
species_filter,
|
| 1087 |
min_confidence,
|
| 1088 |
+
validator_filter,
|
| 1089 |
+
validation_status_filter,
|
| 1090 |
+
updated_after_filter,
|
| 1091 |
show_conflicts_only,
|
| 1092 |
],
|
| 1093 |
outputs=[status, cache_key_state, audio_player, table, page_state, selected_index, pending_status_state, conflict_detection_key_state],
|
| 1094 |
)
|
| 1095 |
batch_approve_conflicts_btn.click(
|
| 1096 |
+
fn=lambda rows, name, notes, cache_key, page, species, confidence, validator_filter_value, status_filter_value, updated_after_value: _batch_validate_conflicts(
|
| 1097 |
validation_service=validation_service,
|
| 1098 |
audio_service=audio_service,
|
| 1099 |
queue_service=service,
|
|
|
|
| 1107 |
page=int(page),
|
| 1108 |
scientific_name=species,
|
| 1109 |
min_confidence=float(confidence),
|
| 1110 |
+
validator_filter=validator_filter_value,
|
| 1111 |
+
status_filter=status_filter_value,
|
| 1112 |
+
updated_after=updated_after_value,
|
| 1113 |
),
|
| 1114 |
+
inputs=[
|
| 1115 |
+
table,
|
| 1116 |
+
validator_name,
|
| 1117 |
+
validation_notes,
|
| 1118 |
+
cache_key_state,
|
| 1119 |
+
page_state,
|
| 1120 |
+
species_filter,
|
| 1121 |
+
min_confidence,
|
| 1122 |
+
validator_filter,
|
| 1123 |
+
validation_status_filter,
|
| 1124 |
+
updated_after_filter,
|
| 1125 |
+
],
|
| 1126 |
outputs=[status, cache_key_state, audio_player, table, page_state],
|
| 1127 |
)
|
| 1128 |
batch_reject_conflicts_btn.click(
|
| 1129 |
+
fn=lambda rows, name, notes, cache_key, page, species, confidence, validator_filter_value, status_filter_value, updated_after_value: _batch_validate_conflicts(
|
| 1130 |
validation_service=validation_service,
|
| 1131 |
audio_service=audio_service,
|
| 1132 |
queue_service=service,
|
|
|
|
| 1140 |
page=int(page),
|
| 1141 |
scientific_name=species,
|
| 1142 |
min_confidence=float(confidence),
|
| 1143 |
+
validator_filter=validator_filter_value,
|
| 1144 |
+
status_filter=status_filter_value,
|
| 1145 |
+
updated_after=updated_after_value,
|
| 1146 |
),
|
| 1147 |
+
inputs=[
|
| 1148 |
+
table,
|
| 1149 |
+
validator_name,
|
| 1150 |
+
validation_notes,
|
| 1151 |
+
cache_key_state,
|
| 1152 |
+
page_state,
|
| 1153 |
+
species_filter,
|
| 1154 |
+
min_confidence,
|
| 1155 |
+
validator_filter,
|
| 1156 |
+
validation_status_filter,
|
| 1157 |
+
updated_after_filter,
|
| 1158 |
+
],
|
| 1159 |
outputs=[status, cache_key_state, audio_player, table, page_state],
|
| 1160 |
)
|
| 1161 |
report_btn.click(
|
tests/unit/test_app_factory_audio_helpers.py
CHANGED
|
@@ -94,12 +94,19 @@ class FakeSnapshotReader:
|
|
| 94 |
"dkey_01": {
|
| 95 |
"status": "positive",
|
| 96 |
"validator": "validator-demo",
|
|
|
|
| 97 |
"version": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
}
|
| 99 |
}
|
| 100 |
self.events: list[dict[str, object]] = [
|
| 101 |
{"detection_key": "dkey_01", "status": "positive"},
|
| 102 |
-
{"detection_key": "
|
| 103 |
]
|
| 104 |
|
| 105 |
def load_current_snapshot(self, project_slug: str) -> dict[str, dict[str, object]]:
|
|
@@ -116,7 +123,7 @@ class FakeQueueService:
|
|
| 116 |
def __init__(self) -> None:
|
| 117 |
self.page = 1
|
| 118 |
self.total_pages = 1
|
| 119 |
-
self.total_items =
|
| 120 |
self.items = [
|
| 121 |
type(
|
| 122 |
"DetectionLike",
|
|
@@ -129,7 +136,19 @@ class FakeQueueService:
|
|
| 129 |
"start_time": 0.0,
|
| 130 |
"end_time": 1.0,
|
| 131 |
},
|
| 132 |
-
)()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
]
|
| 134 |
|
| 135 |
def get_page(self, **kwargs: object) -> "FakeQueueService._Page":
|
|
@@ -249,8 +268,9 @@ def test_build_validation_report() -> None:
|
|
| 249 |
|
| 250 |
assert "Projeto: demo-project" in report
|
| 251 |
assert "Eventos append-only: 2" in report
|
| 252 |
-
assert "Deteccoes com estado atual:
|
| 253 |
assert "positive=1" in report
|
|
|
|
| 254 |
|
| 255 |
|
| 256 |
def test_page_to_table_includes_validation_status() -> None:
|
|
@@ -319,6 +339,51 @@ def test_page_to_table_conflicts_only_filter_keeps_conflict_rows() -> None:
|
|
| 319 |
assert "Apenas conflitos: 1 item(ns)" in status
|
| 320 |
|
| 321 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
def test_find_detection_row_index() -> None:
|
| 323 |
rows = [["dkey_00", "audio_00"], ["dkey_01", "audio_01"]]
|
| 324 |
|
|
@@ -346,6 +411,9 @@ def test_save_selected_validation_with_refresh_success() -> None:
|
|
| 346 |
page=1,
|
| 347 |
scientific_name="",
|
| 348 |
min_confidence=0.0,
|
|
|
|
|
|
|
|
|
|
| 349 |
show_conflicts_only=False,
|
| 350 |
)
|
| 351 |
|
|
@@ -379,6 +447,9 @@ def test_save_selected_validation_with_refresh_conflict() -> None:
|
|
| 379 |
page=1,
|
| 380 |
scientific_name="",
|
| 381 |
min_confidence=0.0,
|
|
|
|
|
|
|
|
|
|
| 382 |
show_conflicts_only=False,
|
| 383 |
)
|
| 384 |
|
|
@@ -416,6 +487,9 @@ def test_reapply_last_conflict_validation_with_refresh() -> None:
|
|
| 416 |
page=1,
|
| 417 |
scientific_name="",
|
| 418 |
min_confidence=0.0,
|
|
|
|
|
|
|
|
|
|
| 419 |
show_conflicts_only=False,
|
| 420 |
)
|
| 421 |
|
|
@@ -450,6 +524,9 @@ def test_reapply_last_conflict_without_pending_status() -> None:
|
|
| 450 |
page=1,
|
| 451 |
scientific_name="",
|
| 452 |
min_confidence=0.0,
|
|
|
|
|
|
|
|
|
|
| 453 |
show_conflicts_only=False,
|
| 454 |
)
|
| 455 |
|
|
@@ -490,6 +567,9 @@ def test_batch_validate_conflicts_all_success() -> None:
|
|
| 490 |
page=1,
|
| 491 |
scientific_name="",
|
| 492 |
min_confidence=0.0,
|
|
|
|
|
|
|
|
|
|
| 493 |
)
|
| 494 |
|
| 495 |
assert "Processados 2 conflitos" in status
|
|
@@ -521,6 +601,9 @@ def test_batch_validate_conflicts_no_conflicts() -> None:
|
|
| 521 |
page=1,
|
| 522 |
scientific_name="",
|
| 523 |
min_confidence=0.0,
|
|
|
|
|
|
|
|
|
|
| 524 |
)
|
| 525 |
|
| 526 |
assert "Nenhuma deteccao com conflito" in status
|
|
|
|
| 94 |
"dkey_01": {
|
| 95 |
"status": "positive",
|
| 96 |
"validator": "validator-demo",
|
| 97 |
+
"updated_at": "2026-03-25T10:00:00+00:00",
|
| 98 |
"version": 2,
|
| 99 |
+
},
|
| 100 |
+
"dkey_02": {
|
| 101 |
+
"status": "negative",
|
| 102 |
+
"validator": "validator-other",
|
| 103 |
+
"updated_at": "2026-03-20T10:00:00+00:00",
|
| 104 |
+
"version": 1,
|
| 105 |
}
|
| 106 |
}
|
| 107 |
self.events: list[dict[str, object]] = [
|
| 108 |
{"detection_key": "dkey_01", "status": "positive"},
|
| 109 |
+
{"detection_key": "dkey_02", "status": "negative"},
|
| 110 |
]
|
| 111 |
|
| 112 |
def load_current_snapshot(self, project_slug: str) -> dict[str, dict[str, object]]:
|
|
|
|
| 123 |
def __init__(self) -> None:
|
| 124 |
self.page = 1
|
| 125 |
self.total_pages = 1
|
| 126 |
+
self.total_items = 2
|
| 127 |
self.items = [
|
| 128 |
type(
|
| 129 |
"DetectionLike",
|
|
|
|
| 136 |
"start_time": 0.0,
|
| 137 |
"end_time": 1.0,
|
| 138 |
},
|
| 139 |
+
)(),
|
| 140 |
+
type(
|
| 141 |
+
"DetectionLike",
|
| 142 |
+
(),
|
| 143 |
+
{
|
| 144 |
+
"detection_key": "dkey_02",
|
| 145 |
+
"audio_id": "audio_02",
|
| 146 |
+
"scientific_name": "sp2",
|
| 147 |
+
"confidence": 0.85,
|
| 148 |
+
"start_time": 1.0,
|
| 149 |
+
"end_time": 2.0,
|
| 150 |
+
},
|
| 151 |
+
)(),
|
| 152 |
]
|
| 153 |
|
| 154 |
def get_page(self, **kwargs: object) -> "FakeQueueService._Page":
|
|
|
|
| 268 |
|
| 269 |
assert "Projeto: demo-project" in report
|
| 270 |
assert "Eventos append-only: 2" in report
|
| 271 |
+
assert "Deteccoes com estado atual: 2" in report
|
| 272 |
assert "positive=1" in report
|
| 273 |
+
assert "negative=1" in report
|
| 274 |
|
| 275 |
|
| 276 |
def test_page_to_table_includes_validation_status() -> None:
|
|
|
|
| 339 |
assert "Apenas conflitos: 1 item(ns)" in status
|
| 340 |
|
| 341 |
|
| 342 |
+
def test_page_to_table_filters_by_validator() -> None:
|
| 343 |
+
rows, _, _ = _page_to_table(
|
| 344 |
+
service=FakeQueueService(),
|
| 345 |
+
snapshot_reader=FakeSnapshotReader(),
|
| 346 |
+
project_slug="demo-project",
|
| 347 |
+
page=1,
|
| 348 |
+
scientific_name="",
|
| 349 |
+
min_confidence=0.0,
|
| 350 |
+
validator_filter="other",
|
| 351 |
+
)
|
| 352 |
+
|
| 353 |
+
assert len(rows) == 1
|
| 354 |
+
assert rows[0][0] == "dkey_02"
|
| 355 |
+
|
| 356 |
+
|
| 357 |
+
def test_page_to_table_filters_by_status() -> None:
|
| 358 |
+
rows, _, _ = _page_to_table(
|
| 359 |
+
service=FakeQueueService(),
|
| 360 |
+
snapshot_reader=FakeSnapshotReader(),
|
| 361 |
+
project_slug="demo-project",
|
| 362 |
+
page=1,
|
| 363 |
+
scientific_name="",
|
| 364 |
+
min_confidence=0.0,
|
| 365 |
+
status_filter="negative",
|
| 366 |
+
)
|
| 367 |
+
|
| 368 |
+
assert len(rows) == 1
|
| 369 |
+
assert rows[0][0] == "dkey_02"
|
| 370 |
+
|
| 371 |
+
|
| 372 |
+
def test_page_to_table_filters_by_updated_after() -> None:
|
| 373 |
+
rows, _, _ = _page_to_table(
|
| 374 |
+
service=FakeQueueService(),
|
| 375 |
+
snapshot_reader=FakeSnapshotReader(),
|
| 376 |
+
project_slug="demo-project",
|
| 377 |
+
page=1,
|
| 378 |
+
scientific_name="",
|
| 379 |
+
min_confidence=0.0,
|
| 380 |
+
updated_after="2026-03-24",
|
| 381 |
+
)
|
| 382 |
+
|
| 383 |
+
assert len(rows) == 1
|
| 384 |
+
assert rows[0][0] == "dkey_01"
|
| 385 |
+
|
| 386 |
+
|
| 387 |
def test_find_detection_row_index() -> None:
|
| 388 |
rows = [["dkey_00", "audio_00"], ["dkey_01", "audio_01"]]
|
| 389 |
|
|
|
|
| 411 |
page=1,
|
| 412 |
scientific_name="",
|
| 413 |
min_confidence=0.0,
|
| 414 |
+
validator_filter="",
|
| 415 |
+
status_filter="all",
|
| 416 |
+
updated_after="",
|
| 417 |
show_conflicts_only=False,
|
| 418 |
)
|
| 419 |
|
|
|
|
| 447 |
page=1,
|
| 448 |
scientific_name="",
|
| 449 |
min_confidence=0.0,
|
| 450 |
+
validator_filter="",
|
| 451 |
+
status_filter="all",
|
| 452 |
+
updated_after="",
|
| 453 |
show_conflicts_only=False,
|
| 454 |
)
|
| 455 |
|
|
|
|
| 487 |
page=1,
|
| 488 |
scientific_name="",
|
| 489 |
min_confidence=0.0,
|
| 490 |
+
validator_filter="",
|
| 491 |
+
status_filter="all",
|
| 492 |
+
updated_after="",
|
| 493 |
show_conflicts_only=False,
|
| 494 |
)
|
| 495 |
|
|
|
|
| 524 |
page=1,
|
| 525 |
scientific_name="",
|
| 526 |
min_confidence=0.0,
|
| 527 |
+
validator_filter="",
|
| 528 |
+
status_filter="all",
|
| 529 |
+
updated_after="",
|
| 530 |
show_conflicts_only=False,
|
| 531 |
)
|
| 532 |
|
|
|
|
| 567 |
page=1,
|
| 568 |
scientific_name="",
|
| 569 |
min_confidence=0.0,
|
| 570 |
+
validator_filter="",
|
| 571 |
+
status_filter="all",
|
| 572 |
+
updated_after="",
|
| 573 |
)
|
| 574 |
|
| 575 |
assert "Processados 2 conflitos" in status
|
|
|
|
| 601 |
page=1,
|
| 602 |
scientific_name="",
|
| 603 |
min_confidence=0.0,
|
| 604 |
+
validator_filter="",
|
| 605 |
+
status_filter="all",
|
| 606 |
+
updated_after="",
|
| 607 |
)
|
| 608 |
|
| 609 |
assert "Nenhuma deteccao com conflito" in status
|