Skip to content

Commit

Permalink
feat: add a route to get all user proofs
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael0202 committed Nov 15, 2023
1 parent 19ee604 commit c4b6a7a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,15 @@ def upload_proof(
return db_proof


@app.get("/proofs", response_model=list[schemas.ProofBase])
def get_user_proofs(current_user: schemas.UserBase = Depends(get_current_user)):
"""Get all the proofs uploaded by the current user.
This endpoint requires authentication.
"""
return crud.get_user_proofs(db, user=current_user)


@app.get("/status")
async def status_endpoint():
return {"status": "running"}
Expand Down
4 changes: 4 additions & 0 deletions app/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def get_proof(db: Session, proof_id: int):
return db.query(Proof).filter(Proof.id == proof_id).first()


def get_user_proofs(db: Session, user: UserBase):
return db.query(Proof).filter(Proof.owner == user.user_id).all()


def create_proof(db: Session, file_path: str, mimetype: str, user: UserBase):
"""Create a proof in the database.
Expand Down

0 comments on commit c4b6a7a

Please sign in to comment.