Skip to content

Commit

Permalink
fix: projects list endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
nrjadkry committed Jul 10, 2024
1 parent 892cde9 commit b0cd1fd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
9 changes: 3 additions & 6 deletions src/backend/app/projects/project_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,19 @@ async def get_project_by_id(

async def get_projects(
db: Database,
author_id: uuid.UUID,
skip: int = 0,
limit: int = 100,
):
"""Get all projects."""
raw_sql = """
SELECT id, name, short_description, description, per_task_instructions, outline
FROM projects
WHERE author_id = :author_id
ORDER BY id DESC
ORDER BY created DESC
OFFSET :skip
LIMIT :limit;
"""
db_projects = await db.fetch_all(
raw_sql, {"author_id": author_id, "skip": skip, "limit": limit}
)
db_projects = await db.fetch_all(raw_sql, {"skip": skip, "limit": limit})

return db_projects


Expand Down
3 changes: 1 addition & 2 deletions src/backend/app/projects/project_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ async def read_projects(
user_data: AuthUser = Depends(login_required),
):
"Return all projects"
author_id = user_data.id
projects = await project_crud.get_projects(db, author_id, skip, limit)
projects = await project_crud.get_projects(db, skip, limit)
return projects


Expand Down

0 comments on commit b0cd1fd

Please sign in to comment.