Skip to content

Commit

Permalink
feat: add /points/:id/notes route
Browse files Browse the repository at this point in the history
  • Loading branch information
seelengxd committed Sep 23, 2024
1 parent 46be709 commit 48f03d8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion backend/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from src.profile.router import router as profile_router
from src.events.router import router as events_router
from src.user_questions.router import router as user_questions_router
from src.notes.router import router as notes_router
from src.notes.router import router as notes_router, points_router
from contextlib import asynccontextmanager

import logging
Expand Down Expand Up @@ -40,3 +40,4 @@ async def lifespan(app: FastAPI):
server.include_router(events_router)
server.include_router(user_questions_router)
server.include_router(notes_router)
server.include_router(points_router)
18 changes: 18 additions & 0 deletions backend/src/notes/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,21 @@ def delete_note(
):
session.delete(note)
session.commit()


points_router = APIRouter(prefix="/points", tags=["points"])


@points_router.get("/:id/notes")
def get_point_notes(
user: Annotated[User, Depends(get_current_user)],
session=Depends(get_session),
):
# TODO: validate point
notes = session.scalars(
select(Note)
.where(Note.parent_id == id)
.where(Note.parent_type == NoteType.POINT)
.where(Note.user_id == user.id)
)
return notes

0 comments on commit 48f03d8

Please sign in to comment.