🐛 fix(manager.py): improve readability by splitting a long line into multiple lines

🐛 fix(utils.py): add comment to explain the reason for the check
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-10-03 17:08:38 -03:00
commit ad406541f2
2 changed files with 6 additions and 1 deletions

View file

@ -66,7 +66,9 @@ class DatabaseService(Service):
if settings_service.auth_settings.AUTO_LOGIN:
with Session(self.engine) as session:
flows = (
session.query(models.Flow).filter(models.Flow.user_id == None).all()
session.query(models.Flow)
.filter(models.Flow.user_id == None) # noqa
.all()
)
if flows:
logger.debug("Migrating flows to default superuser")

View file

@ -58,6 +58,9 @@ def get_or_create_super_user(session: Session, username, password, is_default):
return create_super_user(username, password, db=session)
except Exception as exc:
if "UNIQUE constraint failed: user.username" in str(exc):
# This is to deal with workers running this
# at startup and trying to create the superuser
# at the same time.
logger.debug("Superuser already exists.")
return None