Add delete button to taste profile tags in Stats
- Backend: DELETE /stats/taste/{tag} removes the row from user_tag_affinity
- API: deleteTasteTag(tag) helper
- Stats UI: × button on each tag chip, faint by default, full opacity on hover;
invalidates stats query so the tag disappears immediately
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from sqlalchemy.orm import Session
|
||||
from sqlalchemy import text
|
||||
|
||||
from ..auth_utils import get_current_user
|
||||
from ..database import get_db
|
||||
from ..models import User
|
||||
from ..models import User, UserTagAffinity
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@@ -142,3 +142,16 @@ def get_stats(
|
||||
"top_categories": [dict(r) for r in top_categories],
|
||||
"taste_profile": [dict(r) for r in taste_profile],
|
||||
}
|
||||
|
||||
|
||||
@router.delete("/taste/{tag}", status_code=204)
|
||||
def delete_taste_tag(
|
||||
tag: str,
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
row = db.query(UserTagAffinity).filter_by(user_id=current_user.id, tag=tag).first()
|
||||
if not row:
|
||||
raise HTTPException(status_code=404, detail="Tag not found")
|
||||
db.delete(row)
|
||||
db.commit()
|
||||
|
||||
Reference in New Issue
Block a user