mirror of https://github.com/langgenius/dify.git
fix: page/limit param not effective (#18196)
This commit is contained in:
parent
bbd9fe9777
commit
4166f73d9d
|
@ -122,6 +122,8 @@ class SegmentApi(DatasetApiResource):
|
|||
tenant_id=current_user.current_tenant_id,
|
||||
status_list=args["status"],
|
||||
keyword=args["keyword"],
|
||||
page=page,
|
||||
limit=limit,
|
||||
)
|
||||
|
||||
response = {
|
||||
|
|
|
@ -2175,7 +2175,13 @@ class SegmentService:
|
|||
|
||||
@classmethod
|
||||
def get_segments(
|
||||
cls, document_id: str, tenant_id: str, status_list: list[str] | None = None, keyword: str | None = None
|
||||
cls,
|
||||
document_id: str,
|
||||
tenant_id: str,
|
||||
status_list: list[str] | None = None,
|
||||
keyword: str | None = None,
|
||||
page: int = 1,
|
||||
limit: int = 20,
|
||||
):
|
||||
"""Get segments for a document with optional filtering."""
|
||||
query = DocumentSegment.query.filter(
|
||||
|
@ -2188,10 +2194,11 @@ class SegmentService:
|
|||
if keyword:
|
||||
query = query.filter(DocumentSegment.content.ilike(f"%{keyword}%"))
|
||||
|
||||
segments = query.order_by(DocumentSegment.position.asc()).all()
|
||||
total = len(segments)
|
||||
paginated_segments = query.order_by(DocumentSegment.position.asc()).paginate(
|
||||
page=page, per_page=limit, max_per_page=100, error_out=False
|
||||
)
|
||||
|
||||
return segments, total
|
||||
return paginated_segments.items, paginated_segments.total
|
||||
|
||||
@classmethod
|
||||
def update_segment_by_id(
|
||||
|
|
Loading…
Reference in New Issue