
- Setup project structure and basic FastAPI application - Define database models for users, profiles, matches, and messages - Set up database connection and create Alembic migrations - Implement user authentication and registration endpoints - Create API endpoints for profile management, matches, and messaging - Add filtering and search functionality for tech profiles - Setup environment variable configuration - Create README with project information and setup instructions
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
from typing import List, Optional
|
|
from sqlalchemy.orm import Session
|
|
from sqlalchemy import or_, and_
|
|
|
|
from app.crud.base import CRUDBase
|
|
from app.models.match import Match, MatchStatusEnum
|
|
from app.schemas.match import MatchCreate, MatchUpdate
|
|
|
|
|
|
class CRUDMatch(CRUDBase[Match, MatchCreate, MatchUpdate]):
|
|
def get_by_users(
|
|
self, db: Session, *, user1_id: int, user2_id: int
|
|
) -> Optional[Match]:
|
|
return db.query(Match).filter(
|
|
or_(
|
|
and_(Match.sender_id == user1_id, Match.receiver_id == user2_id),
|
|
and_(Match.sender_id == user2_id, Match.receiver_id == user1_id)
|
|
)
|
|
).first()
|
|
|
|
def get_user_matches(
|
|
self, db: Session, *, user_id: int, status: Optional[MatchStatusEnum] = None, skip: int = 0, limit: int = 100
|
|
) -> List[Match]:
|
|
query = db.query(Match).filter(
|
|
or_(
|
|
Match.sender_id == user_id,
|
|
Match.receiver_id == user_id
|
|
)
|
|
)
|
|
|
|
if status:
|
|
query = query.filter(Match.status == status)
|
|
|
|
return query.offset(skip).limit(limit).all()
|
|
|
|
|
|
match = CRUDMatch(Match) |