Spaces:
Sleeping
Sleeping
revert admin page to FileLock-compatible imports
Browse files- src/app.py +17 -11
src/app.py
CHANGED
|
@@ -115,7 +115,10 @@ from src.ui.screens_preference import screen_pair_intro
|
|
| 115 |
# ---------------------------------------------------------------------------
|
| 116 |
def _screen_admin(cfg: dict) -> None:
|
| 117 |
"""Coverage dashboard β visit ?admin=1 to see this."""
|
| 118 |
-
from src.data import
|
|
|
|
|
|
|
|
|
|
| 119 |
|
| 120 |
st.markdown("## π Study Coverage Dashboard")
|
| 121 |
st.caption(
|
|
@@ -125,22 +128,25 @@ def _screen_admin(cfg: dict) -> None:
|
|
| 125 |
)
|
| 126 |
|
| 127 |
if st.button("π Refresh", type="primary"):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
st.rerun()
|
| 129 |
|
| 130 |
-
hf_state = _fetch_hf_state(cfg)
|
| 131 |
-
|
| 132 |
for cat_cfg in cfg["categories"]:
|
| 133 |
-
cat
|
| 134 |
-
pool
|
| 135 |
total = len(pool)
|
| 136 |
|
| 137 |
-
|
| 138 |
-
|
|
|
|
| 139 |
|
| 140 |
-
covered = sum(1 for v in
|
| 141 |
reserved_uncovered = sum(
|
| 142 |
-
1 for
|
| 143 |
-
if
|
| 144 |
)
|
| 145 |
truly_uncovered = total - covered - reserved_uncovered
|
| 146 |
|
|
@@ -149,7 +155,7 @@ def _screen_admin(cfg: dict) -> None:
|
|
| 149 |
col1.metric("Total items", total)
|
| 150 |
col2.metric("Covered β
", covered)
|
| 151 |
col3.metric("In progress π", reserved_uncovered,
|
| 152 |
-
help="Reserved by active users
|
| 153 |
col4.metric("Still needed β οΈ", truly_uncovered,
|
| 154 |
delta=f"-{truly_uncovered}" if truly_uncovered > 0 else None,
|
| 155 |
delta_color="inverse")
|
|
|
|
| 115 |
# ---------------------------------------------------------------------------
|
| 116 |
def _screen_admin(cfg: dict) -> None:
|
| 117 |
"""Coverage dashboard β visit ?admin=1 to see this."""
|
| 118 |
+
from src.data import (
|
| 119 |
+
_get_accepted_counts, _load_pool, _pool_path,
|
| 120 |
+
_load_reservations, _expire_reservations,
|
| 121 |
+
)
|
| 122 |
|
| 123 |
st.markdown("## π Study Coverage Dashboard")
|
| 124 |
st.caption(
|
|
|
|
| 128 |
)
|
| 129 |
|
| 130 |
if st.button("π Refresh", type="primary"):
|
| 131 |
+
# Invalidate HF completion caches so we re-scan
|
| 132 |
+
from src.data import _data_dir
|
| 133 |
+
for f in _data_dir(cfg).glob("completion_cache*"):
|
| 134 |
+
f.unlink()
|
| 135 |
st.rerun()
|
| 136 |
|
|
|
|
|
|
|
| 137 |
for cat_cfg in cfg["categories"]:
|
| 138 |
+
cat = cat_cfg["name"]
|
| 139 |
+
pool = _load_pool(str(_pool_path(cat, cfg)))
|
| 140 |
total = len(pool)
|
| 141 |
|
| 142 |
+
counts = _get_accepted_counts(cat, cfg)
|
| 143 |
+
reservations = _load_reservations(cfg)
|
| 144 |
+
_expire_reservations(reservations)
|
| 145 |
|
| 146 |
+
covered = sum(1 for v in counts.values() if v >= 1)
|
| 147 |
reserved_uncovered = sum(
|
| 148 |
+
1 for k in reservations
|
| 149 |
+
if counts.get(k, 0) == 0
|
| 150 |
)
|
| 151 |
truly_uncovered = total - covered - reserved_uncovered
|
| 152 |
|
|
|
|
| 155 |
col1.metric("Total items", total)
|
| 156 |
col2.metric("Covered β
", covered)
|
| 157 |
col3.metric("In progress π", reserved_uncovered,
|
| 158 |
+
help="Reserved by active users β will complete soon")
|
| 159 |
col4.metric("Still needed β οΈ", truly_uncovered,
|
| 160 |
delta=f"-{truly_uncovered}" if truly_uncovered > 0 else None,
|
| 161 |
delta_color="inverse")
|