Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions api/core/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ def create_access_token(data: dict, expires_delta: Optional[timedelta] = None) -
else:
expire = datetime.utcnow() + timedelta(minutes=settings.ACCESS_TOKEN_EXPIRE_MINUTES)
to_encode.update({"exp": expire})
encoded_jwt = jwt.encode(
return jwt.encode(
to_encode, settings.SECRET_KEY, algorithm=ALGORITHM)
return encoded_jwt
Comment on lines -36 to -38
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function create_access_token refactored with the following changes:



def verify_password(plain_password: str, hashed_password: str) -> bool:
Expand Down
8 changes: 2 additions & 6 deletions api/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,8 @@ def get_tweets_for_user(db: Session, user_id: int, skip: int = 0, limit: int = 1
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST, detail="User does not exist")

# user exists - proceed to return tweets
tweets = db.query(models.Tweet).filter(models.Tweet.user_id == user_id).order_by(
return db.query(models.Tweet).filter(models.Tweet.user_id == user_id).order_by(
models.Tweet.created_at.desc()).limit(limit).all()
return tweets
Comment on lines -151 to -154
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function get_tweets_for_user refactored with the following changes:

This removes the following comments ( why? ):

# user exists - proceed to return tweets



def get_tweets_liked_by_user(db: Session, user_id: int, skip: int = 0, limit: int = 100):
Expand Down Expand Up @@ -390,10 +388,8 @@ def get_all_followers(db: Session, user_id: int):
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST,
detail="Bad userId. User does not exist.")

# User is valid - proceed to get all followers
db_followers = db.query(models.Follows).filter(
return db.query(models.Follows).filter(
models.Follows.follows_user_id == user_id).all()
return db_followers
Comment on lines -393 to -396
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function get_all_followers refactored with the following changes:

This removes the following comments ( why? ):

# User is valid - proceed to get all followers


###############
# Tweet Likes #
Expand Down
4 changes: 1 addition & 3 deletions api/routers/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ def update_user(request_body: schemas.UserUpdateRequestBody,
raise HTTPException(
status_code=status.HTTP_406_NOT_ACCEPTABLE, detail="Username already exists")

# Update user attributes
user = crud.update_user(db, current_user.id, request_body)
return user
return crud.update_user(db, current_user.id, request_body)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function update_user refactored with the following changes:

This removes the following comments ( why? ):

# Update user attributes



@router.delete('/', response_model=schemas.EmptyResponse)
Expand Down