Spaces:
Sleeping
Sleeping
Update database_schema.py
Browse files- database_schema.py +13 -7
database_schema.py
CHANGED
|
@@ -173,6 +173,17 @@ class DynamicHighscoresDB:
|
|
| 173 |
row = cursor.fetchone()
|
| 174 |
return dict(row) if row else None
|
| 175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
def can_submit_today(self, user_id):
|
| 177 |
"""Check if a user can submit a benchmark evaluation today."""
|
| 178 |
cursor = self.get_cursor()
|
|
@@ -320,7 +331,7 @@ class DynamicHighscoresDB:
|
|
| 320 |
row = cursor.fetchone()
|
| 321 |
return dict(row) if row else None
|
| 322 |
|
| 323 |
-
|
| 324 |
def add_evaluation(self, model_id, benchmark_id, priority=0):
|
| 325 |
"""Add a new evaluation to the database and queue."""
|
| 326 |
cursor = self.get_cursor()
|
|
@@ -469,9 +480,4 @@ class DynamicHighscoresDB:
|
|
| 469 |
if not df.empty and 'score' in df.columns:
|
| 470 |
df = df.sort_values('score', ascending=False)
|
| 471 |
|
| 472 |
-
return df
|
| 473 |
-
|
| 474 |
-
def init_db(db_path="dynamic_highscores.db"):
|
| 475 |
-
"""Initialize and return the database manager."""
|
| 476 |
-
db = DynamicHighscoresDB(db_path)
|
| 477 |
-
return db
|
|
|
|
| 173 |
row = cursor.fetchone()
|
| 174 |
return dict(row) if row else None
|
| 175 |
|
| 176 |
+
def get_user_by_username(self, username):
|
| 177 |
+
"""Get user information by username."""
|
| 178 |
+
cursor = self.get_cursor()
|
| 179 |
+
|
| 180 |
+
cursor.execute(
|
| 181 |
+
"SELECT * FROM users WHERE username = ?",
|
| 182 |
+
(username,)
|
| 183 |
+
)
|
| 184 |
+
row = cursor.fetchone()
|
| 185 |
+
return dict(row) if row else None
|
| 186 |
+
|
| 187 |
def can_submit_today(self, user_id):
|
| 188 |
"""Check if a user can submit a benchmark evaluation today."""
|
| 189 |
cursor = self.get_cursor()
|
|
|
|
| 331 |
row = cursor.fetchone()
|
| 332 |
return dict(row) if row else None
|
| 333 |
|
| 334 |
+
# Evaluation management methods
|
| 335 |
def add_evaluation(self, model_id, benchmark_id, priority=0):
|
| 336 |
"""Add a new evaluation to the database and queue."""
|
| 337 |
cursor = self.get_cursor()
|
|
|
|
| 480 |
if not df.empty and 'score' in df.columns:
|
| 481 |
df = df.sort_values('score', ascending=False)
|
| 482 |
|
| 483 |
+
return df
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|