Hurum Maksora Tohfa commited on
Refactor feedback logging and update stats display
Browse files
app.py
CHANGED
|
@@ -256,6 +256,8 @@ if run_btn:
|
|
| 256 |
"n_papers": len(downloaded),
|
| 257 |
"n_figures": len(all_figures),
|
| 258 |
}
|
|
|
|
|
|
|
| 259 |
|
| 260 |
except Exception as e:
|
| 261 |
log(f"✗ Error: {e}")
|
|
@@ -342,22 +344,21 @@ if st.session_state.results and st.session_state.results.get("matches"):
|
|
| 342 |
)
|
| 343 |
|
| 344 |
if st.button("Submit feedback", key="submit_feedback"):
|
| 345 |
-
|
| 346 |
-
st.session_state.
|
| 347 |
st.success("Thanks!")
|
| 348 |
|
| 349 |
|
| 350 |
-
# Persistent tally
|
| 351 |
-
|
| 352 |
-
n_ratings = len(
|
| 353 |
-
avg = sum(
|
| 354 |
-
searches = tally.get("searches", 0)
|
| 355 |
|
| 356 |
st.markdown(f"""
|
| 357 |
<div class="tally-box">
|
| 358 |
-
<div class="tally-title">
|
| 359 |
<div class="tally-row">
|
| 360 |
-
<div class="stat-item"><div class="tally-num">{searches}</div><div class="tally-label">Searches</div></div>
|
| 361 |
<div class="stat-item"><div class="tally-num">{n_ratings}</div><div class="tally-label">Rated</div></div>
|
| 362 |
<div class="stat-item"><div class="tally-num">{"—" if not n_ratings else f"{avg:.1f}"}</div><div class="tally-label">Avg score</div></div>
|
| 363 |
</div>
|
|
|
|
| 256 |
"n_papers": len(downloaded),
|
| 257 |
"n_figures": len(all_figures),
|
| 258 |
}
|
| 259 |
+
log_search(query, len(downloaded), len(verified), total_cost)
|
| 260 |
+
st.session_state.global_stats["searches"] += 1
|
| 261 |
|
| 262 |
except Exception as e:
|
| 263 |
log(f"✗ Error: {e}")
|
|
|
|
| 344 |
)
|
| 345 |
|
| 346 |
if st.button("Submit feedback", key="submit_feedback"):
|
| 347 |
+
log_rating(rating)
|
| 348 |
+
st.session_state.global_stats["ratings"].append(rating)
|
| 349 |
st.success("Thanks!")
|
| 350 |
|
| 351 |
|
| 352 |
+
# Persistent tally
|
| 353 |
+
stats = st.session_state.global_stats
|
| 354 |
+
n_ratings = len(stats["ratings"])
|
| 355 |
+
avg = sum(stats["ratings"]) / n_ratings if n_ratings else 0
|
|
|
|
| 356 |
|
| 357 |
st.markdown(f"""
|
| 358 |
<div class="tally-box">
|
| 359 |
+
<div class="tally-title">Overall stats</div>
|
| 360 |
<div class="tally-row">
|
| 361 |
+
<div class="stat-item"><div class="tally-num">{stats['searches']}</div><div class="tally-label">Searches</div></div>
|
| 362 |
<div class="stat-item"><div class="tally-num">{n_ratings}</div><div class="tally-label">Rated</div></div>
|
| 363 |
<div class="stat-item"><div class="tally-num">{"—" if not n_ratings else f"{avg:.1f}"}</div><div class="tally-label">Avg score</div></div>
|
| 364 |
</div>
|