fix: Videos page links to show, hide test users from leaderboard
Some checks are pending
Deploy Elmeg / deploy (push) Waiting to run
Some checks are pending
Deploy Elmeg / deploy (push) Waiting to run
- Videos page now links song titles to show page (where video is displayed) - Leaderboard hides tenwest/testuser until 12+ real users exist
This commit is contained in:
parent
cddd3e2389
commit
1f7f83a31a
2 changed files with 27 additions and 11 deletions
|
|
@ -222,11 +222,27 @@ def check_and_award_badges(session: Session, user: User) -> List[Badge]:
|
|||
|
||||
def get_leaderboard(session: Session, limit: int = 10) -> List[dict]:
|
||||
"""Get top users by XP"""
|
||||
users = session.exec(
|
||||
select(User)
|
||||
# Test accounts to hide until we have real users
|
||||
TEST_USER_EMAILS = ["tenwest", "testuser"]
|
||||
MIN_USERS_TO_SHOW_TEST = 12
|
||||
|
||||
# Count total real users
|
||||
total_users = session.exec(
|
||||
select(func.count(User.id))
|
||||
.where(User.is_active == True)
|
||||
.order_by(User.xp.desc())
|
||||
.limit(limit)
|
||||
).one() or 0
|
||||
|
||||
# Build query
|
||||
query = select(User).where(User.is_active == True)
|
||||
|
||||
# If we don't have enough real users, hide test accounts
|
||||
if total_users < MIN_USERS_TO_SHOW_TEST:
|
||||
for test_email in TEST_USER_EMAILS:
|
||||
query = query.where(~User.email.ilike(f"{test_email}@%"))
|
||||
query = query.where(~User.email.ilike(f"%{test_email}%"))
|
||||
|
||||
users = session.exec(
|
||||
query.order_by(User.xp.desc()).limit(limit)
|
||||
).all()
|
||||
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -107,8 +107,8 @@ export default function VideosPage() {
|
|||
<button
|
||||
onClick={() => setActiveTab("all")}
|
||||
className={`px-4 py-2 rounded-lg text-sm font-medium transition-colors ${activeTab === "all"
|
||||
? "bg-primary text-primary-foreground"
|
||||
: "bg-muted hover:bg-muted/80"
|
||||
? "bg-primary text-primary-foreground"
|
||||
: "bg-muted hover:bg-muted/80"
|
||||
}`}
|
||||
>
|
||||
All Videos
|
||||
|
|
@ -116,8 +116,8 @@ export default function VideosPage() {
|
|||
<button
|
||||
onClick={() => setActiveTab("songs")}
|
||||
className={`px-4 py-2 rounded-lg text-sm font-medium transition-colors ${activeTab === "songs"
|
||||
? "bg-primary text-primary-foreground"
|
||||
: "bg-muted hover:bg-muted/80"
|
||||
? "bg-primary text-primary-foreground"
|
||||
: "bg-muted hover:bg-muted/80"
|
||||
}`}
|
||||
>
|
||||
<Music className="h-4 w-4 inline mr-1" />
|
||||
|
|
@ -126,8 +126,8 @@ export default function VideosPage() {
|
|||
<button
|
||||
onClick={() => setActiveTab("shows")}
|
||||
className={`px-4 py-2 rounded-lg text-sm font-medium transition-colors ${activeTab === "shows"
|
||||
? "bg-primary text-primary-foreground"
|
||||
: "bg-muted hover:bg-muted/80"
|
||||
? "bg-primary text-primary-foreground"
|
||||
: "bg-muted hover:bg-muted/80"
|
||||
}`}
|
||||
>
|
||||
<Film className="h-4 w-4 inline mr-1" />
|
||||
|
|
@ -167,7 +167,7 @@ export default function VideosPage() {
|
|||
</Link>
|
||||
) : (
|
||||
<Link
|
||||
href={`/songs/${(video as PerformanceVideo).song_slug || (video as PerformanceVideo).song_id}`}
|
||||
href={`/shows/${(video as PerformanceVideo).show_slug || (video as PerformanceVideo).show_id}`}
|
||||
className="font-medium hover:underline"
|
||||
>
|
||||
{(video as PerformanceVideo).song_title}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue