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,
|
tenant_id=current_user.current_tenant_id,
|
||||||
status_list=args["status"],
|
status_list=args["status"],
|
||||||
keyword=args["keyword"],
|
keyword=args["keyword"],
|
||||||
|
page=page,
|
||||||
|
limit=limit,
|
||||||
)
|
)
|
||||||
|
|
||||||
response = {
|
response = {
|
||||||
|
|
|
@ -2175,7 +2175,13 @@ class SegmentService:
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_segments(
|
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."""
|
"""Get segments for a document with optional filtering."""
|
||||||
query = DocumentSegment.query.filter(
|
query = DocumentSegment.query.filter(
|
||||||
|
@ -2188,10 +2194,11 @@ class SegmentService:
|
||||||
if keyword:
|
if keyword:
|
||||||
query = query.filter(DocumentSegment.content.ilike(f"%{keyword}%"))
|
query = query.filter(DocumentSegment.content.ilike(f"%{keyword}%"))
|
||||||
|
|
||||||
segments = query.order_by(DocumentSegment.position.asc()).all()
|
paginated_segments = query.order_by(DocumentSegment.position.asc()).paginate(
|
||||||
total = len(segments)
|
page=page, per_page=limit, max_per_page=100, error_out=False
|
||||||
|
)
|
||||||
|
|
||||||
return segments, total
|
return paginated_segments.items, paginated_segments.total
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def update_segment_by_id(
|
def update_segment_by_id(
|
||||||
|
|
Loading…
Reference in New Issue