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:
Mattias Tall
2026-05-26 11:07:32 +02:00
parent a4cd32da4a
commit d6dd07e0bd
3 changed files with 33 additions and 5 deletions

View File

@@ -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()