Skip to content

Commit

Permalink
Revert "disable all chunks status when disable document (#12149)"
Browse files Browse the repository at this point in the history
This reverts commit 5a3fe61.
  • Loading branch information
laipz8200 committed Jan 2, 2025
1 parent 714b22d commit ad0146f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 26 deletions.
16 changes: 1 addition & 15 deletions api/tasks/add_document_to_index_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ def add_document_to_index_task(dataset_document_id: str):
try:
segments = (
db.session.query(DocumentSegment)
.filter(
DocumentSegment.document_id == dataset_document.id,
DocumentSegment.enabled == False,
DocumentSegment.status == "completed",
)
.filter(DocumentSegment.document_id == dataset_document.id, DocumentSegment.enabled == True)
.order_by(DocumentSegment.position.asc())
.all()
)
Expand Down Expand Up @@ -89,16 +85,6 @@ def add_document_to_index_task(dataset_document_id: str):
db.session.query(DatasetAutoDisableLog).filter(
DatasetAutoDisableLog.document_id == dataset_document.id
).delete()

# update segment to enable
db.session.query(DocumentSegment).filter(DocumentSegment.document_id == dataset_document.id).update(
{
DocumentSegment.enabled: True,
DocumentSegment.disabled_at: None,
DocumentSegment.disabled_by: None,
DocumentSegment.updated_at: datetime.datetime.now(datetime.UTC).replace(tzinfo=None),
}
)
db.session.commit()

end_at = time.perf_counter()
Expand Down
11 changes: 0 additions & 11 deletions api/tasks/remove_document_from_index_task.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import datetime
import logging
import time

Expand Down Expand Up @@ -47,16 +46,6 @@ def remove_document_from_index_task(document_id: str):
index_processor.clean(dataset, index_node_ids, with_keywords=True, delete_child_chunks=False)
except Exception:
logging.exception(f"clean dataset {dataset.id} from index failed")
# update segment to disable
db.session.query(DocumentSegment).filter(DocumentSegment.document_id == document.id).update(
{
DocumentSegment.enabled: False,
DocumentSegment.disabled_at: datetime.datetime.now(datetime.UTC).replace(tzinfo=None),
DocumentSegment.disabled_by: document.disabled_by,
DocumentSegment.updated_at: datetime.datetime.now(datetime.UTC).replace(tzinfo=None),
}
)
db.session.commit()

end_at = time.perf_counter()
logging.info(
Expand Down

0 comments on commit ad0146f

Please sign in to comment.