Remove redundant attributes in the file index (#41)
This commit is contained in:
parent
c6045bcb9f
commit
749c9e5641
|
@ -63,7 +63,6 @@ class FileIndex(BaseIndex):
|
||||||
"relation_type": Column(Integer),
|
"relation_type": Column(Integer),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
self._db_tables: dict[str, Any] = {"Source": Source, "Index": Index}
|
|
||||||
self._vs: BaseVectorStore = get_vectorstore(f"index_{self.id}")
|
self._vs: BaseVectorStore = get_vectorstore(f"index_{self.id}")
|
||||||
self._docstore: BaseDocumentStore = get_docstore(f"index_{self.id}")
|
self._docstore: BaseDocumentStore = get_docstore(f"index_{self.id}")
|
||||||
self._fs_path = filestorage_path / f"index_{self.id}"
|
self._fs_path = filestorage_path / f"index_{self.id}"
|
||||||
|
|
|
@ -199,8 +199,8 @@ class FileIndexPage(BasePage):
|
||||||
def delete_yes_event(self, file_id):
|
def delete_yes_event(self, file_id):
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
source = session.execute(
|
source = session.execute(
|
||||||
select(self._index._db_tables["Source"]).where(
|
select(self._index._resources["Source"]).where(
|
||||||
self._index._db_tables["Source"].id == file_id
|
self._index._resources["Source"].id == file_id
|
||||||
)
|
)
|
||||||
).first()
|
).first()
|
||||||
if source:
|
if source:
|
||||||
|
@ -208,8 +208,8 @@ class FileIndexPage(BasePage):
|
||||||
|
|
||||||
vs_ids, ds_ids = [], []
|
vs_ids, ds_ids = [], []
|
||||||
index = session.execute(
|
index = session.execute(
|
||||||
select(self._index._db_tables["Index"]).where(
|
select(self._index._resources["Index"]).where(
|
||||||
self._index._db_tables["Index"].source_id == file_id
|
self._index._resources["Index"].source_id == file_id
|
||||||
)
|
)
|
||||||
).all()
|
).all()
|
||||||
for each in index:
|
for each in index:
|
||||||
|
@ -431,7 +431,7 @@ class FileIndexPage(BasePage):
|
||||||
return self.index_fn(files, reindex, settings)
|
return self.index_fn(files, reindex, settings)
|
||||||
|
|
||||||
def list_file(self):
|
def list_file(self):
|
||||||
Source = self._index._db_tables["Source"]
|
Source = self._index._resources["Source"]
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
statement = select(Source)
|
statement = select(Source)
|
||||||
results = [
|
results = [
|
||||||
|
@ -494,7 +494,7 @@ class FileIndexPage(BasePage):
|
||||||
if max_number_of_files := self._index.config.get("max_number_of_files", 0):
|
if max_number_of_files := self._index.config.get("max_number_of_files", 0):
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
current_num_files = session.query(
|
current_num_files = session.query(
|
||||||
self._index._db_tables["Source"].id
|
self._index._resources["Source"].id
|
||||||
).count()
|
).count()
|
||||||
if len(paths) + current_num_files > max_number_of_files:
|
if len(paths) + current_num_files > max_number_of_files:
|
||||||
errors.append(
|
errors.append(
|
||||||
|
@ -566,7 +566,7 @@ class FileSelector(BasePage):
|
||||||
options = []
|
options = []
|
||||||
available_ids = []
|
available_ids = []
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
statement = select(self._index._db_tables["Source"])
|
statement = select(self._index._resources["Source"])
|
||||||
results = session.execute(statement).all()
|
results = session.execute(statement).all()
|
||||||
for result in results:
|
for result in results:
|
||||||
available_ids.append(result[0].id)
|
available_ids.append(result[0].id)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user