refactor: remove user search from global search - irrelevant for music archive
This commit is contained in:
parent
8990063837
commit
3de9a7cb3f
1 changed files with 3 additions and 27 deletions
|
|
@ -3,8 +3,8 @@ from fastapi import APIRouter, Depends, HTTPException, Query
|
|||
from sqlmodel import Session, select, col
|
||||
from sqlalchemy.orm import selectinload
|
||||
from database import get_session
|
||||
from models import Show, Song, Venue, Tour, User, Group, Performance, PerformanceNickname, Comment, Review
|
||||
from schemas import ShowRead, SongRead, VenueRead, TourRead, UserRead, GroupRead
|
||||
from models import Show, Song, Venue, Tour, Group, Performance, PerformanceNickname, Comment, Review
|
||||
from schemas import ShowRead, SongRead, VenueRead, TourRead, GroupRead
|
||||
|
||||
router = APIRouter(prefix="/search", tags=["search"])
|
||||
|
||||
|
|
@ -47,29 +47,6 @@ def global_search(
|
|||
.limit(limit)
|
||||
).all()
|
||||
|
||||
# Search Users (by email or profile username)
|
||||
users = session.exec(
|
||||
select(User)
|
||||
.where(col(User.email).ilike(q_str))
|
||||
.limit(limit)
|
||||
).all()
|
||||
|
||||
# Also search Profiles for username matches
|
||||
from models import Profile
|
||||
profile_matches = session.exec(
|
||||
select(Profile)
|
||||
.where(col(Profile.username).ilike(q_str))
|
||||
.limit(limit)
|
||||
).all()
|
||||
# Add unique users from profile matches
|
||||
existing_user_ids = {u.id for u in users}
|
||||
for p in profile_matches:
|
||||
if p.user_id not in existing_user_ids:
|
||||
user = session.get(User, p.user_id)
|
||||
if user:
|
||||
users.append(user)
|
||||
existing_user_ids.add(user.id)
|
||||
|
||||
# Search Nicknames
|
||||
nicknames = session.exec(
|
||||
select(PerformanceNickname)
|
||||
|
|
@ -79,7 +56,7 @@ def global_search(
|
|||
.limit(limit)
|
||||
).all()
|
||||
|
||||
# Search Performances
|
||||
# Search Performances by notes
|
||||
performances = session.exec(
|
||||
select(Performance)
|
||||
.options(selectinload(Performance.song), selectinload(Performance.show))
|
||||
|
|
@ -109,7 +86,6 @@ def global_search(
|
|||
"venues": venues,
|
||||
"tours": tours,
|
||||
"groups": groups,
|
||||
"users": users,
|
||||
"nicknames": nicknames,
|
||||
"performances": performances,
|
||||
"reviews": reviews,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue