refactor: simplify schema names and remove provider id columns
This commit is contained in:
@@ -19,7 +19,7 @@ class SystemsRepository:
|
||||
count_stmt = select(func.count()).select_from(System)
|
||||
if keyword:
|
||||
pattern = f"%{keyword}%"
|
||||
cond = or_(System.system_key.ilike(pattern), System.name.ilike(pattern), System.provider_client_id.ilike(pattern))
|
||||
cond = or_(System.system_key.ilike(pattern), System.name.ilike(pattern))
|
||||
stmt = stmt.where(cond)
|
||||
count_stmt = count_stmt.where(cond)
|
||||
if status:
|
||||
@@ -29,8 +29,8 @@ class SystemsRepository:
|
||||
stmt = stmt.order_by(System.created_at.desc()).limit(limit).offset(offset)
|
||||
return list(self.db.scalars(stmt).all()), int(self.db.scalar(count_stmt) or 0)
|
||||
|
||||
def create(self, *, system_key: str, name: str, provider_client_id: str, status: str = "active") -> System:
|
||||
item = System(system_key=system_key, name=name, provider_client_id=provider_client_id, status=status)
|
||||
def create(self, *, system_key: str, name: str, status: str = "active") -> System:
|
||||
item = System(system_key=system_key, name=name, status=status)
|
||||
self.db.add(item)
|
||||
self.db.commit()
|
||||
self.db.refresh(item)
|
||||
@@ -41,13 +41,10 @@ class SystemsRepository:
|
||||
item: System,
|
||||
*,
|
||||
name: str | None = None,
|
||||
provider_client_id: str | None = None,
|
||||
status: str | None = None,
|
||||
) -> System:
|
||||
if name is not None:
|
||||
item.name = name
|
||||
if provider_client_id is not None:
|
||||
item.provider_client_id = provider_client_id
|
||||
if status is not None:
|
||||
item.status = status
|
||||
self.db.commit()
|
||||
|
||||
Reference in New Issue
Block a user