Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
fjpacheco committed Mar 12, 2024
1 parent 8df6a6c commit 93268ea
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
5 changes: 3 additions & 2 deletions app/models/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

class User(Base):
__tablename__ = "users"
__table_args__ = {'schema': \
environ.get("POSTGRES_SCHEMA", "users_service")}
__table_args__ = {"schema": environ.get(
"POSTGRES_SCHEMA",
"users_service")}
id = Column(Integer, primary_key=True, index=True, autoincrement=True)
name = Column(String, nullable=True)
email = Column(String, nullable=False)
Expand Down
27 changes: 16 additions & 11 deletions app/repository/Users.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@


class UsersRepository:
db_url = environ.get("DATABASE_URL").replace("postgres://",
"postgresql://",
1)
db_url = environ.get(
"DATABASE_URL").replace(
"postgres://",
"postgresql://",
1)

engine = create_engine(db_url)

Expand All @@ -35,18 +37,21 @@ def get_all_users(self):
users = self.session.query(User).all()
return self.__parse_result(users)

def create_user(self, email: str,
name: Optional[str] = None,
gender: Optional[str] = None,
photo: Optional[str] = None):
user_data = {'email': email}
def create_user(
self,
email: str,
name: Optional[str] = None,
gender: Optional[str] = None,
photo: Optional[str] = None,
):
user_data = {"email": email}

if name is not None:
user_data['name'] = name
user_data["name"] = name
if gender is not None:
user_data['gender'] = gender
user_data["gender"] = gender
if photo is not None:
user_data['photo'] = photo
user_data["photo"] = photo

new_user = User(**user_data)
self.session.add(new_user)
Expand Down

0 comments on commit 93268ea

Please sign in to comment.