Explorar el Código

Remove dead code (#3210)

### What problem does this PR solve?

Remove dead code

### Type of change

- [x] Refactoring
tags/v0.14.0
Zhichang Yu hace 1 año
padre
commit
38ebf6b2c0
No account linked to committer's email address
Se han modificado 2 ficheros con 1 adiciones y 55 borrados
  1. 1
    30
      api/db/services/document_service.py
  2. 0
    25
      api/db/services/knowledgebase_service.py

+ 1
- 30
api/db/services/document_service.py Ver fichero

@@ -95,35 +95,6 @@ class DocumentService(CommonService):

return list(docs.dicts()), count

@classmethod
@DB.connection_context()
def list_documents_in_dataset(cls, dataset_id, offset, count, order_by, descend, keywords):
if keywords:
docs = cls.model.select().where(
(cls.model.kb_id == dataset_id),
(fn.LOWER(cls.model.name).contains(keywords.lower()))
)
else:
docs = cls.model.select().where(cls.model.kb_id == dataset_id)

total = docs.count()

if descend == 'True':
docs = docs.order_by(cls.model.getter_by(order_by).desc())
if descend == 'False':
docs = docs.order_by(cls.model.getter_by(order_by).asc())

docs = list(docs.dicts())
docs_length = len(docs)

if offset < 0 or offset > docs_length:
raise IndexError("Offset is out of the valid range.")

if count == -1:
return docs[offset:], total

return docs[offset:offset + count], total

@classmethod
@DB.connection_context()
def insert(cls, doc):
@@ -426,7 +397,7 @@ class DocumentService(CommonService):
try:
_, doc = DocumentService.get_by_id(doc_id)
return doc.run == TaskStatus.CANCEL.value or doc.progress < 0
except Exception as e:
except Exception:
pass
return False


+ 0
- 25
api/db/services/knowledgebase_service.py Ver fichero

@@ -66,31 +66,6 @@ class KnowledgebaseService(CommonService):

return list(kbs.dicts())

@classmethod
@DB.connection_context()
def get_by_tenant_ids_by_offset(cls, joined_tenant_ids, user_id, offset, count, orderby, desc):
kbs = cls.model.select().where(
((cls.model.tenant_id.in_(joined_tenant_ids) & (cls.model.permission ==
TenantPermission.TEAM.value)) | (
cls.model.tenant_id == user_id))
& (cls.model.status == StatusEnum.VALID.value)
)
if desc:
kbs = kbs.order_by(cls.model.getter_by(orderby).desc())
else:
kbs = kbs.order_by(cls.model.getter_by(orderby).asc())

kbs = list(kbs.dicts())

kbs_length = len(kbs)
if offset < 0 or offset > kbs_length:
raise IndexError("Offset is out of the valid range.")

if count == -1:
return kbs[offset:]

return kbs[offset:offset + count]

@classmethod
@DB.connection_context()
def get_detail(cls, kb_id):

Cargando…
Cancelar
Guardar