Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions python/valuecell/server/api/routers/user_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

from fastapi import APIRouter, HTTPException, Path, Query

from ...db.models.user_profile import ProfileCategory
from ...services.user_profile_service import get_user_profile_service
from ..schemas import SuccessResponse
from ..schemas.user_profile import (
CreateUserProfileRequest,
ProfileCategoryEnum,
UpdateUserProfileRequest,
UserProfileData,
UserProfileListData,
Expand Down Expand Up @@ -39,7 +39,7 @@ async def create_profile(request: CreateUserProfileRequest):
user_id = DEFAULT_USER_ID

# Validate category
valid_categories = [e.value for e in ProfileCategoryEnum]
valid_categories = [e.value for e in ProfileCategory]
if request.category not in valid_categories:
raise HTTPException(
status_code=400,
Expand Down Expand Up @@ -77,7 +77,7 @@ async def create_profile(request: CreateUserProfileRequest):
async def get_profiles(
category: Optional[str] = Query(
None,
description=f"Filter by category ({', '.join([e.value for e in ProfileCategoryEnum])})",
description=f"Filter by category ({', '.join([e.value for e in ProfileCategory])})",
),
):
"""Get all user profiles."""
Expand All @@ -87,7 +87,7 @@ async def get_profiles(

# Validate category if provided
if category:
valid_categories = [e.value for e in ProfileCategoryEnum]
valid_categories = [e.value for e in ProfileCategory]
if category not in valid_categories:
raise HTTPException(
status_code=400,
Expand Down
12 changes: 2 additions & 10 deletions python/valuecell/server/api/schemas/user_profile.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
"""API schemas for user profile operations."""

import enum
from datetime import datetime
from typing import List

from pydantic import BaseModel, Field


class ProfileCategoryEnum(str, enum.Enum):
"""Profile category enum for API."""

PRODUCT_BEHAVIOR = "product_behavior"
RISK_PREFERENCE = "risk_preference"
READING_PREFERENCE = "reading_preference"
NORMAL = "normal"
from ...db.models.user_profile import ProfileCategory


class UserProfileData(BaseModel):
Expand All @@ -32,7 +24,7 @@ class CreateUserProfileRequest(BaseModel):

category: str = Field(
...,
description=f"Profile category: {', '.join([e.value for e in ProfileCategoryEnum])}",
description=f"Profile category: {', '.join([e.value for e in ProfileCategory])}",
)
content: str = Field(
..., description="Profile content", min_length=1, max_length=10000
Expand Down
1 change: 1 addition & 0 deletions python/valuecell/server/db/models/user_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ProfileCategory(str, enum.Enum):
PRODUCT_BEHAVIOR = "product_behavior" # User's behavior on products
RISK_PREFERENCE = "risk_preference" # User's risk preference
READING_PREFERENCE = "reading_preference" # User's reading preference
NORMAL = "normal" # User's normal profile


class UserProfile(Base):
Expand Down