Fix/interface home (#182)
* [fix]Fix the interface for statistics of recent activities and applications * [changes]Modify the code based on the AI review 1.Use the boolean auxiliary methods provided by SQLAlchemy instead of using == True in the is_active filter. 2.The calculation of the "PROJECT_ROOT" has now been hardcoded with five levels of nested os.path.dirname calls. * [fix]Fix the interface for statistics of recent activities and applications * [changes]Modify the code based on the AI review 1.Use the boolean auxiliary methods provided by SQLAlchemy instead of using == True in the is_active filter. 2.The calculation of the "PROJECT_ROOT" has now been hardcoded with five levels of nested os.path.dirname calls.
This commit is contained in:
@@ -68,7 +68,7 @@ class UserRepository:
|
||||
db_logger.debug("查询超级用户")
|
||||
|
||||
try:
|
||||
user = self.db.query(User).options(joinedload(User.tenant)).filter(User.is_active == True).filter(User.is_superuser == True).first()
|
||||
user = self.db.query(User).options(joinedload(User.tenant)).filter(User.is_active.is_(True)).filter(User.is_superuser.is_(True)).first()
|
||||
if user:
|
||||
db_logger.debug(f"超级用户查询成功: {user.username}")
|
||||
else:
|
||||
@@ -82,7 +82,7 @@ class UserRepository:
|
||||
db_logger.debug("检查是否只有一个超级用户")
|
||||
|
||||
try:
|
||||
count = self.db.query(User).options(joinedload(User.tenant)).filter(User.is_active == True).filter(User.is_superuser == True).count()
|
||||
count = self.db.query(User).options(joinedload(User.tenant)).filter(User.is_active.is_(True)).filter(User.is_superuser.is_(True)).count()
|
||||
return count == 1
|
||||
except Exception as e:
|
||||
db_logger.error(f"检查超级用户数量失败: {str(e)}")
|
||||
|
||||
Reference in New Issue
Block a user