|
@@ -1,7 +1,6 @@
|
|
|
import os
|
|
|
import shutil
|
|
|
import typing as T
|
|
|
-import warnings
|
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
@@ -120,56 +119,6 @@ class Project(NamedBaseModel):
|
|
|
return self.files.filter(File.id == identifier).one_or_none()
|
|
|
|
|
|
|
|
|
- def label_tree(self) -> T.List[Label]:
|
|
|
- """
|
|
|
- get a list of root labels associated with this project
|
|
|
-
|
|
|
- :return: list of labels
|
|
|
- """
|
|
|
- warnings.warn("Check performance of this method!")
|
|
|
- # pylint: disable=no-member
|
|
|
- return self.labels.filter(Label.parent_id.is_(None)).all()
|
|
|
-
|
|
|
-
|
|
|
- def label_tree_original(self):
|
|
|
- """
|
|
|
- get a list of root labels associated with this project
|
|
|
-
|
|
|
- :return: list of labels
|
|
|
- """
|
|
|
- raise NotImplementedError
|
|
|
- # pylint: disable=unreachable
|
|
|
- # pylint: disable=pointless-string-statement
|
|
|
- """
|
|
|
- with closing(self.database.con.cursor()) as cursor:
|
|
|
- cursor.execute('''
|
|
|
- WITH RECURSIVE
|
|
|
- tree AS (
|
|
|
- SELECT labels.* FROM labels
|
|
|
- WHERE project = ? AND parent IS NULL
|
|
|
- UNION ALL
|
|
|
- SELECT labels.* FROM labels
|
|
|
- JOIN tree ON labels.parent = tree.id
|
|
|
- )
|
|
|
- SELECT * FROM tree
|
|
|
- ''', [self.id])
|
|
|
-
|
|
|
- result = []
|
|
|
- lookup = {}
|
|
|
-
|
|
|
- for row in cursor.fetchall():
|
|
|
- label = TreeNodeLabel(self.database, row)
|
|
|
- lookup[label.id] = label
|
|
|
-
|
|
|
- if label.parent_id is None:
|
|
|
- result.append(label)
|
|
|
- else:
|
|
|
- lookup[label.parent_id].children.append(label)
|
|
|
-
|
|
|
- return result
|
|
|
- """
|
|
|
-
|
|
|
-
|
|
|
def collection(self, identifier: int) -> T.Optional[Collection]:
|
|
|
"""
|
|
|
get a collection using its unique identifier
|