Skip to content

Commit

Permalink
remove none if in secondary index gets
Browse files Browse the repository at this point in the history
  • Loading branch information
Adibuer-lab committed Jun 27, 2024
1 parent f4993ed commit e222c51
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/users/src/users_service/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,7 @@ def get_user_by_username(username: str) -> Optional[User]:
KeyConditionExpression=Key('username').eq(username)
)
items = response.get('Items', [])
return User.from_dict(items[0]) if items else None
except User.dynamodb.meta.client.exceptions.ResourceNotFoundException:
return User()
return User.from_dict(items[0])
except ClientError as e:
current_app.logger.error(f"Error getting user by username: {str(e)}")
return None
Expand All @@ -217,9 +215,7 @@ def get_user_by_identity_id(identity_id: str) -> Optional[User]:
KeyConditionExpression=Key('identity_id').eq(identity_id)
)
items = response.get('Items', [])
return User.from_dict(items[0]) if items else None
except User.dynamodb.meta.client.exceptions.ResourceNotFoundException:
return User()
return User.from_dict(items[0])
except ClientError as e:
current_app.logger.error(f"Error getting user by identity_id: {str(e)}")
return None
Expand Down

0 comments on commit e222c51

Please sign in to comment.