Skip to content

added patch and delete endpoint for category and patch endpoint for transaction..#13

Open
aryaman-adhikari wants to merge 5 commits into
mainfrom
adding_models
Open

added patch and delete endpoint for category and patch endpoint for transaction..#13
aryaman-adhikari wants to merge 5 commits into
mainfrom
adding_models

Conversation

@aryaman-adhikari

Copy link
Copy Markdown
Collaborator

added patch and delete endpoint for category and patch endpoint for transaction..

@vercel

vercel Bot commented Dec 30, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
finance-tracker Ready Ready Preview, Comment Jan 8, 2026 2:19pm

Comment thread db/database.py
Comment thread routes/categoryRoutes.py Outdated
Comment on lines +84 to +85
if not request.state.user:
raise HTTPException(status_code=401, detail="Not authenticated")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required... Handle this in auth middleware in better way

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okayy

Comment thread routes/categoryRoutes.py Outdated
user_id = request.state.user.id
db.query(models.Transaction).filter(
models.Transaction.user_id == user_id
).delete(synchronize_session=False)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this synchronize session do?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when we delete in bulk there could be objects loaded by python in memoey soo in default session tries to scan the memory and if matches any object marks it as deleted and deletes from database . But when i make synchronize_session =false then our route doesn't care about the memory it just deletes from the database. Soo, the merit of using it is to skip the unnecessary scanning .Simply means don't care about memory just delete from the database .Both of them works though .In our case we need to delete i bulk i mean transactions could be in bulk soo why scanning in memory and wasting time just skip the process

Comment thread routes/categoryRoutes.py Outdated
Comment on lines +107 to +109
if not request.state.user:
raise HTTPException(status_code=401, detail="Not authenticated")
user_id = request.state.user.id

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

Comment thread routes/categoryRoutes.py Outdated
db.refresh(category)
return {
"message": "Category updated successfully",
"category": category

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just return the id

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay done

Comment thread schemas/schemas.py
Comment thread schemas/schemas.py
Comment thread schemas/schemas.py
color: str
icon: str


Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Comment thread schemas/schemas.py
Comment thread schemas/schemas.py
Comment thread routes/transactions.py
Comment thread routes/categoryRoutes.py
Comment thread routes/categoryRoutes.py Outdated
Comment thread middlewares/authMiddleWare.py Outdated
Comment thread middlewares/authMiddleWare.py Outdated
user = get_user_from_token(token, db)
if user:
request.state.user = user
print("USER:", request.state.user)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this line

Comment thread middlewares/authMiddleWare.py Outdated
except (KeyError, ValueError, DecodeError):
raise HTTPException(status_code=401, detail="Invalid authentication token")

return db.query(models.User).filter(models.User.id == user_id).first()

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handle error for when no user is found

Comment thread routes/authRoutes.py Outdated
):
users = db.query(models.User).all()
return {"users": users}
return users

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return in a json and proper format

Comment thread routes/categoryRoutes.py Outdated
current_user: models.User = Depends(require_auth),
):
categories = db.query(models.Category).filter(models.Category.user_id == current_user.id).all()
return categories

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return in a proper json format

Comment thread routes/categoryRoutes.py
):
user_id = request.state.user.id
categories = db.query(models.Category).filter(models.Category.user_id == user_id).all()
categories = db.query(models.Category).filter(

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a single category... rename it to category

Comment thread routes/categoryRoutes.py Outdated

return {"categories": categories}
raise HTTPException(status_code=404, detail="Category not found")
return categories

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use proper json format

Comment thread routes/categoryRoutes.py


if not category_to_delete:
@router.delete("/categories/{category_id}")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe related transaction should be deleted first

Comment thread routes/transactions.py Outdated
Comment on lines +62 to +64
user = db.query(models.User).filter(
models.User.id == current_user.id
).first()

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already get the user from the middleware

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants