Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: api error of get all workspaces (#15880)

csurongc3774bef7e79
diff --git a/api/controllers/console/workspace/workspace.py b/api/controllers/console/workspace/workspace.py
index eb12ec77d8b..27fb5134eea 100644
--- a/api/controllers/console/workspace/workspace.py
+++ b/api/controllers/console/workspace/workspace.py
@@ -88,28 +88,20 @@ class WorkspaceListApi(Resource):
parser.add_argument("limit", type=inputs.int_range(1, 100), required=False, default=20, location="args")
args = parser.parse_args()
- tenants = Tenant.query.order_by(Tenant.created_at.desc()).paginate(page=args["page"], per_page=args["limit"])
-
+ tenants = Tenant.query.order_by(Tenant.created_at.desc()).paginate(
+ page=args["page"], per_page=args["limit"], error_out=False
+ )
has_more = False
- if len(tenants.items) == args["limit"]:
- current_page_first_tenant = tenants[-1]
- rest_count = (
- db.session.query(Tenant)
- .filter(
- Tenant.created_at < current_page_first_tenant.created_at, Tenant.id != current_page_first_tenant.id
- )
- .count()
- )
- if rest_count > 0:
- has_more = True
- total = db.session.query(Tenant).count()
+ if tenants.has_next:
+ has_more = True
+
return {
"data": marshal(tenants.items, workspace_fields),
"has_more": has_more,
"limit": args["limit"],
"page": args["page"],
- "total": total,
+ "total": tenants.total,
}, 200