| """UI logic for the "Estadístiques" page.""" |
|
|
| from __future__ import annotations |
|
|
| import pandas as pd |
| import streamlit as st |
|
|
| from database import get_feedback_ad_stats |
|
|
|
|
| def render_statistics_page() -> None: |
| st.header("Estadístiques") |
|
|
| stats = get_feedback_ad_stats() |
| if not stats: |
| st.caption("Encara no hi ha valoracions.") |
| st.stop() |
|
|
| df = pd.DataFrame(stats, columns=stats[0].keys()) |
| ordre = st.radio( |
| "Ordre de rànquing", |
| ["Descendent (millors primer)", "Ascendent (pitjors primer)"], |
| horizontal=True, |
| ) |
| if ordre.startswith("Asc"): |
| df = df.sort_values("avg_global", ascending=True) |
| else: |
| df = df.sort_values("avg_global", ascending=False) |
|
|
| st.subheader("Rànquing de vídeos") |
| st.dataframe( |
| df[ |
| [ |
| "video_name", |
| "n", |
| "avg_global", |
| "avg_transcripcio", |
| "avg_identificacio", |
| "avg_localitzacions", |
| "avg_activitats", |
| "avg_narracions", |
| "avg_expressivitat", |
| ] |
| ], |
| use_container_width=True, |
| ) |
|
|