Spaces:
Sleeping
Sleeping
Download app/users/models.py from yzffm/radarscholar-api: direct link, hf CLI and curl.
- Browser
- Download file 3.54 kB
-
https://huggingface.co/spaces/yzffm/radarscholar-api/resolve/main/app/users/models.py
- Command line
-
hf download hf://spaces/yzffm/radarscholar-api/app/users/models.py
-
curl -L -o models.py https://huggingface.co/spaces/yzffm/radarscholar-api/resolve/main/app/users/models.py
3.54 kB
| """User Profile SQLAlchemy model. | |
| Stores user academic profile, experience, and interests data. | |
| The primary key `id` maps to Supabase `auth.users.id` UUID. | |
| All profile fields from Technical Docs §4 are included to | |
| avoid field mismatches in future milestones (M5 Matching, M9 AI Assistant). | |
| """ | |
| import enum | |
| from sqlalchemy import ( | |
| JSON, | |
| Boolean, | |
| Column, | |
| DateTime, | |
| Enum, | |
| Float, | |
| Integer, | |
| String, | |
| Text, | |
| ) | |
| from sqlalchemy.dialects.postgresql import ARRAY, UUID | |
| from app.core.time import utc_now | |
| from app.database.base import Base | |
| class DegreeLevel(str, enum.Enum): | |
| """Academic degree levels supported by RadarScholar.""" | |
| D3 = "D3" | |
| D4 = "D4" | |
| S1 = "S1" | |
| S2 = "S2" | |
| S3 = "S3" | |
| class UserProfile(Base): | |
| """User profile table. | |
| Maps 1:1 with Supabase auth.users via the `id` column. | |
| Contains academic data, experience, and interest fields | |
| used for scholarship matching (M5) and AI assistance (M9). | |
| """ | |
| __tablename__ = "user_profiles" | |
| # Primary key matches Supabase auth.users.id | |
| id = Column( | |
| UUID(as_uuid=False), | |
| primary_key=True, | |
| comment="Supabase auth user UUID", | |
| ) | |
| # Basic identity | |
| email = Column(String(320), nullable=False, index=True) | |
| display_name = Column(String(255), nullable=True) | |
| avatar_url = Column(Text, nullable=True) | |
| is_admin = Column(Boolean, nullable=False, default=False) | |
| # === Academic (Technical Docs §4 — Academic) === | |
| nationality = Column(String(100), nullable=True) | |
| university = Column(String(255), nullable=True) | |
| faculty = Column(String(255), nullable=True) | |
| major = Column(String(255), nullable=True) | |
| degree_level = Column( | |
| Enum(DegreeLevel, name="degree_level_enum"), | |
| nullable=True, | |
| ) | |
| semester = Column(Integer, nullable=True) | |
| gpa = Column(Float, nullable=True) | |
| # === Experience (Technical Docs §4 — Experience) === | |
| # Stored as PostgreSQL arrays for MVP simplicity. | |
| # Can be normalized to separate tables if needed later. | |
| organizations = Column(JSON().with_variant(ARRAY(Text), 'postgresql'), nullable=True, default=list) | |
| achievements = Column(JSON().with_variant(ARRAY(Text), 'postgresql'), nullable=True, default=list) | |
| competitions = Column(JSON().with_variant(ARRAY(Text), 'postgresql'), nullable=True, default=list) | |
| volunteering = Column(JSON().with_variant(ARRAY(Text), 'postgresql'), nullable=True, default=list) | |
| internships = Column(JSON().with_variant(ARRAY(Text), 'postgresql'), nullable=True, default=list) | |
| certifications = Column(JSON().with_variant(ARRAY(Text), 'postgresql'), nullable=True, default=list) | |
| skills = Column(JSON().with_variant(ARRAY(Text), 'postgresql'), nullable=True, default=list) | |
| # === Interests (Technical Docs §4 — Interests) === | |
| career_interests = Column(JSON().with_variant(ARRAY(Text), 'postgresql'), nullable=True, default=list) | |
| fields_of_interest = Column(JSON().with_variant(ARRAY(Text), 'postgresql'), nullable=True, default=list) | |
| goals = Column(Text, nullable=True) | |
| # === Timestamps === | |
| created_at = Column( | |
| DateTime, | |
| nullable=False, | |
| default=utc_now, | |
| ) | |
| updated_at = Column( | |
| DateTime, | |
| nullable=False, | |
| default=utc_now, | |
| onupdate=utc_now, | |
| ) | |
| def __repr__(self) -> str: | |
| return f"<UserProfile id={self.id} email={self.email}>" | |