|
9 | 9 |
|
10 | 10 | sql = """ |
11 | 11 | UPDATE "document" |
12 | | -SET status ="replace"("replace"("replace"(status, '1', '2'),'0','3'),'2','3') |
| 12 | +SET status ="replace"("replace"("replace"(status, '2', '3'),'0','3'),'1','2') |
| 13 | +""" |
| 14 | +sql_paragraph = """ |
| 15 | +UPDATE "paragraph" |
| 16 | +SET status ="replace"("replace"("replace"(status, '2', '3'),'0','3'),'1','2') |
13 | 17 | """ |
14 | 18 |
|
15 | 19 |
|
16 | 20 | def updateDocumentStatus(apps, schema_editor): |
17 | | - ParagraphModel = apps.get_model('dataset', 'Paragraph') |
18 | 21 | DocumentModel = apps.get_model('dataset', 'Document') |
19 | | - success_list = QuerySet(DocumentModel).filter(status='2') |
20 | | - if len(success_list) == 0: |
21 | | - return |
22 | | - ListenerManagement.update_status(QuerySet(ParagraphModel).filter(document_id__in=[d.id for d in success_list]), |
23 | | - TaskType.EMBEDDING, State.SUCCESS) |
24 | 22 | ListenerManagement.get_aggregation_document_status_by_query_set(QuerySet(DocumentModel))() |
25 | 23 |
|
26 | 24 |
|
@@ -50,6 +48,7 @@ class Migration(migrations.Migration): |
50 | 48 | name='status', |
51 | 49 | field=models.CharField(default=dataset.models.data_set.Status.__str__, max_length=20, verbose_name='状态'), |
52 | 50 | ), |
| 51 | + migrations.RunSQL(sql_paragraph), |
53 | 52 | migrations.RunSQL(sql), |
54 | 53 | migrations.RunPython(updateDocumentStatus) |
55 | 54 | ] |
0 commit comments