mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-06-27 16:10:30 +08:00
exclude banned users from leaderboard
This commit is contained in:
@@ -102,7 +102,7 @@ class UserStatsRepository:
|
||||
UserStats,
|
||||
)
|
||||
.join(UserStats, User.id == UserStats.user_id)
|
||||
.filter(UserStats.time_frame == time_frame.value, User.show_on_leaderboard)
|
||||
.filter(UserStats.time_frame == time_frame.value, User.show_on_leaderboard, User.enabled)
|
||||
.order_by(UserStats.rank)
|
||||
.limit(limit)
|
||||
)
|
||||
@@ -121,7 +121,7 @@ class UserStatsRepository:
|
||||
window_size: int = 5,
|
||||
) -> LeaderboardStats | None:
|
||||
# no window for users who don't show themselves
|
||||
if not user.show_on_leaderboard:
|
||||
if not user.show_on_leaderboard or not user.enabled:
|
||||
return None
|
||||
|
||||
qry = self.session.query(UserStats).filter(UserStats.user_id == user.id, UserStats.time_frame == time_frame)
|
||||
@@ -144,7 +144,7 @@ class UserStatsRepository:
|
||||
UserStats,
|
||||
)
|
||||
.join(UserStats, User.id == UserStats.user_id)
|
||||
.filter(UserStats.time_frame == time_frame.value, User.show_on_leaderboard)
|
||||
.filter(UserStats.time_frame == time_frame.value, User.show_on_leaderboard, User.enabled)
|
||||
.where(UserStats.rank >= min_rank, UserStats.rank <= max_rank)
|
||||
.order_by(UserStats.rank)
|
||||
)
|
||||
@@ -547,7 +547,7 @@ FROM
|
||||
ORDER BY leader_score DESC, user_id
|
||||
) AS "rank", user_id, time_frame
|
||||
FROM user_stats us2
|
||||
INNER JOIN "user" u ON us2.user_id = u.id AND u.show_on_leaderboard
|
||||
INNER JOIN "user" u ON us2.user_id = u.id AND u.show_on_leaderboard AND u.enabled
|
||||
WHERE (:time_frame IS NULL OR time_frame = :time_frame)) AS r
|
||||
WHERE
|
||||
us.user_id = r.user_id
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
|
||||
|
||||
# switch to backend directory
|
||||
pushd "$parent_path/../../backend"
|
||||
|
||||
export DEBUG_USE_SEED_DATA=True
|
||||
export DEBUG_SKIP_TOXICITY_CALCULATION=True
|
||||
export DEBUG_ALLOW_SELF_LABELING=True
|
||||
export DEBUG_ALLOW_SELF_RANKING=True
|
||||
export DEBUG_ALLOW_DUPLICATE_TASKS=True
|
||||
export DEBUG_SKIP_EMBEDDING_COMPUTATION=True
|
||||
export RATE_LIMIT=0
|
||||
export DEBUG_USE_SEED_DATA_PATH=$parent_path/../../backend/test_data/generic/test_generic_data.json
|
||||
|
||||
uvicorn main:app --reload --port 8080 --host 0.0.0.0
|
||||
|
||||
popd
|
||||
Reference in New Issue
Block a user