Update app.py
Browse files
app.py
CHANGED
|
@@ -86,13 +86,13 @@ def update_dashboard():
|
|
| 86 |
"""
|
| 87 |
dataset = fetch_data(os.getenv("DATASET_NAME"), os.getenv("WORKSPACE"))
|
| 88 |
if not dataset:
|
| 89 |
-
return pd.DataFrame(columns=["
|
| 90 |
|
| 91 |
user_annotations = get_leaderboard(dataset)
|
| 92 |
leaderboard_df = pd.DataFrame(
|
| 93 |
-
list(user_annotations.items()), columns=["
|
| 94 |
)
|
| 95 |
-
leaderboard_df = leaderboard_df.sort_values("
|
| 96 |
|
| 97 |
# Reset index for better display
|
| 98 |
leaderboard_df.reset_index(drop=True, inplace=True)
|
|
@@ -124,15 +124,17 @@ h1 {
|
|
| 124 |
border-radius: 10px;
|
| 125 |
overflow: hidden;
|
| 126 |
background-color: white; /* Fondo blanco para la tabla */
|
|
|
|
| 127 |
}
|
| 128 |
|
| 129 |
.dataframe th, .dataframe td {
|
| 130 |
padding: 12px 15px;
|
| 131 |
text-align: left;
|
|
|
|
| 132 |
}
|
| 133 |
|
| 134 |
.dataframe th {
|
| 135 |
-
background-color: #
|
| 136 |
color: white;
|
| 137 |
font-weight: bold;
|
| 138 |
}
|
|
@@ -182,17 +184,33 @@ h1 {
|
|
| 182 |
.dataframe tr:nth-child(5) td:first-child::before {
|
| 183 |
content: "🎖️ "; /* Emoji para el 4º y 5º puesto */
|
| 184 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
"""
|
| 186 |
|
| 187 |
|
| 188 |
# Gradio Interface
|
| 189 |
with gr.Blocks(css=custom_css) as demo:
|
| 190 |
-
gr.Markdown("# Ranking Contribuciones Letras Carnaval Cádiz")
|
| 191 |
|
| 192 |
with gr.Row():
|
| 193 |
leaderboard_output = gr.Dataframe(
|
| 194 |
-
label="
|
| 195 |
-
headers=["
|
| 196 |
datatype=["str", "number"],
|
| 197 |
interactive=False,
|
| 198 |
elem_classes="dataframe",
|
|
@@ -203,7 +221,7 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 203 |
inputs=None,
|
| 204 |
outputs=[leaderboard_output],
|
| 205 |
)
|
| 206 |
-
gr.Button("
|
| 207 |
update_dashboard,
|
| 208 |
inputs=None,
|
| 209 |
outputs=[leaderboard_output],
|
|
|
|
| 86 |
"""
|
| 87 |
dataset = fetch_data(os.getenv("DATASET_NAME"), os.getenv("WORKSPACE"))
|
| 88 |
if not dataset:
|
| 89 |
+
return pd.DataFrame(columns=["Usuario", "Contribuciones"])
|
| 90 |
|
| 91 |
user_annotations = get_leaderboard(dataset)
|
| 92 |
leaderboard_df = pd.DataFrame(
|
| 93 |
+
list(user_annotations.items()), columns=["Usuario", "Contribuciones"]
|
| 94 |
)
|
| 95 |
+
leaderboard_df = leaderboard_df.sort_values("Contribuciones", ascending=False).head(5)
|
| 96 |
|
| 97 |
# Reset index for better display
|
| 98 |
leaderboard_df.reset_index(drop=True, inplace=True)
|
|
|
|
| 124 |
border-radius: 10px;
|
| 125 |
overflow: hidden;
|
| 126 |
background-color: white; /* Fondo blanco para la tabla */
|
| 127 |
+
border: 1px solid white; /* Líneas separadoras blancas */
|
| 128 |
}
|
| 129 |
|
| 130 |
.dataframe th, .dataframe td {
|
| 131 |
padding: 12px 15px;
|
| 132 |
text-align: left;
|
| 133 |
+
border-bottom: 1px solid white; /* Líneas separadoras blancas */
|
| 134 |
}
|
| 135 |
|
| 136 |
.dataframe th {
|
| 137 |
+
background-color: #6c757d; /* Color más neutro (gris) */
|
| 138 |
color: white;
|
| 139 |
font-weight: bold;
|
| 140 |
}
|
|
|
|
| 184 |
.dataframe tr:nth-child(5) td:first-child::before {
|
| 185 |
content: "🎖️ "; /* Emoji para el 4º y 5º puesto */
|
| 186 |
}
|
| 187 |
+
|
| 188 |
+
/* Estilo para el botón */
|
| 189 |
+
button {
|
| 190 |
+
width: auto !important; /* Ancho automático */
|
| 191 |
+
padding: 10px 20px !important; /* Padding más pequeño */
|
| 192 |
+
font-size: 16px !important;
|
| 193 |
+
background-color: #6c757d !important; /* Color más neutro */
|
| 194 |
+
color: white !important;
|
| 195 |
+
border: none !important;
|
| 196 |
+
border-radius: 5px !important;
|
| 197 |
+
cursor: pointer !important;
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
button:hover {
|
| 201 |
+
background-color: #5a6268 !important; /* Color más oscuro al pasar el ratón */
|
| 202 |
+
}
|
| 203 |
"""
|
| 204 |
|
| 205 |
|
| 206 |
# Gradio Interface
|
| 207 |
with gr.Blocks(css=custom_css) as demo:
|
| 208 |
+
gr.Markdown("# 🏆 Ranking Contribuciones Letras Carnaval Cádiz") # Emoji en el título
|
| 209 |
|
| 210 |
with gr.Row():
|
| 211 |
leaderboard_output = gr.Dataframe(
|
| 212 |
+
label="Top 5 Contribuidores", # Título sin <span>
|
| 213 |
+
headers=["Usuario", "Contribuciones"], # Cambiado a "Usuario" y "Contribuciones"
|
| 214 |
datatype=["str", "number"],
|
| 215 |
interactive=False,
|
| 216 |
elem_classes="dataframe",
|
|
|
|
| 221 |
inputs=None,
|
| 222 |
outputs=[leaderboard_output],
|
| 223 |
)
|
| 224 |
+
gr.Button("🔄 Actualizar").click( # Emoji en el botón y texto "Actualizar"
|
| 225 |
update_dashboard,
|
| 226 |
inputs=None,
|
| 227 |
outputs=[leaderboard_output],
|