hotfix: clear_all_annotations should also execute delete_annotation_index_task just like delete_app_annotation (#23093)
Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
4c65a8091a
commit
51a6b9dc57
1 changed files with 11 additions and 0 deletions
|
|
@ -452,6 +452,11 @@ class AppAnnotationService:
|
||||||
if not app:
|
if not app:
|
||||||
raise NotFound("App not found")
|
raise NotFound("App not found")
|
||||||
|
|
||||||
|
# if annotation reply is enabled, delete annotation index
|
||||||
|
app_annotation_setting = (
|
||||||
|
db.session.query(AppAnnotationSetting).where(AppAnnotationSetting.app_id == app_id).first()
|
||||||
|
)
|
||||||
|
|
||||||
annotations_query = db.session.query(MessageAnnotation).filter(MessageAnnotation.app_id == app_id)
|
annotations_query = db.session.query(MessageAnnotation).filter(MessageAnnotation.app_id == app_id)
|
||||||
for annotation in annotations_query.yield_per(100):
|
for annotation in annotations_query.yield_per(100):
|
||||||
annotation_hit_histories_query = db.session.query(AppAnnotationHitHistory).filter(
|
annotation_hit_histories_query = db.session.query(AppAnnotationHitHistory).filter(
|
||||||
|
|
@ -460,6 +465,12 @@ class AppAnnotationService:
|
||||||
for annotation_hit_history in annotation_hit_histories_query.yield_per(100):
|
for annotation_hit_history in annotation_hit_histories_query.yield_per(100):
|
||||||
db.session.delete(annotation_hit_history)
|
db.session.delete(annotation_hit_history)
|
||||||
|
|
||||||
|
# if annotation reply is enabled, delete annotation index
|
||||||
|
if app_annotation_setting:
|
||||||
|
delete_annotation_index_task.delay(
|
||||||
|
annotation.id, app_id, current_user.current_tenant_id, app_annotation_setting.collection_binding_id
|
||||||
|
)
|
||||||
|
|
||||||
db.session.delete(annotation)
|
db.session.delete(annotation)
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue