优化站点激活状态的判断逻辑,简化数据库查询条件

This commit is contained in:
jxxghp
2025-08-19 11:23:09 +08:00
parent d48c6b98e8
commit aeb297efcf
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -317,7 +317,7 @@ class SiteChain(ChainBase):
indexer = siteshelper.get_indexer(domain) indexer = siteshelper.get_indexer(domain)
# 数据库的站点信息 # 数据库的站点信息
site_info = siteoper.get_by_domain(domain) site_info = siteoper.get_by_domain(domain)
if site_info and site_info.is_active == 1: if site_info and site_info.is_active:
# 站点已存在,检查站点连通性 # 站点已存在,检查站点连通性
status, msg = self.test(domain) status, msg = self.test(domain)
# 更新站点Cookie # 更新站点Cookie
+2 -2
View File
@@ -69,12 +69,12 @@ class Site(Base):
@classmethod @classmethod
@db_query @db_query
def get_actives(cls, db: Session): def get_actives(cls, db: Session):
return db.query(cls).filter(cls.is_active == 1).all() return db.query(cls).filter(cls.is_active).all()
@classmethod @classmethod
@async_db_query @async_db_query
async def async_get_actives(cls, db: AsyncSession): async def async_get_actives(cls, db: AsyncSession):
result = await db.execute(select(cls).where(cls.is_active == 1)) result = await db.execute(select(cls).where(cls.is_active))
return result.scalars().all() return result.scalars().all()
@classmethod @classmethod