diff --git a/modules/routes/routeRagInventory.py b/modules/routes/routeRagInventory.py index 08d2a245..37fb330b 100644 --- a/modules/routes/routeRagInventory.py +++ b/modules/routes/routeRagInventory.py @@ -36,6 +36,16 @@ def _buildConnectionInventory(connections, rootIf, knowledgeIf, jobService) -> L connIndexRows = knowledgeIf.db.getRecordset(FileContentIndex, recordFilter={"connectionId": connectionId}) connChunkTotal = len(connIndexRows) + chunksByDs: Dict[str, int] = {} + unassigned = 0 + for idx in connIndexRows: + prov = (idx.get("provenance") if isinstance(idx, dict) else getattr(idx, "provenance", None)) or {} + dsIdRef = prov.get("dataSourceId", "") if isinstance(prov, dict) else "" + if dsIdRef: + chunksByDs[dsIdRef] = chunksByDs.get(dsIdRef, 0) + 1 + else: + unassigned += 1 + dsItems = [] for ds in dataSources: dsId = ds.get("id") if isinstance(ds, dict) else getattr(ds, "id", "") @@ -47,11 +57,11 @@ def _buildConnectionInventory(connections, rootIf, knowledgeIf, jobService) -> L "ragIndexEnabled": ds.get("ragIndexEnabled") if isinstance(ds, dict) else getattr(ds, "ragIndexEnabled", False), "neutralize": ds.get("neutralize") if isinstance(ds, dict) else getattr(ds, "neutralize", False), "lastIndexed": ds.get("lastIndexed") if isinstance(ds, dict) else getattr(ds, "lastIndexed", None), - "chunkCount": 0, + "chunkCount": chunksByDs.get(dsId, 0), }) - if dsItems and connChunkTotal > 0 and len(dsItems) == 1: - dsItems[0]["chunkCount"] = connChunkTotal + if unassigned > 0 and len(dsItems) == 1: + dsItems[0]["chunkCount"] += unassigned jobs = jobService.listJobs(jobType="connection.bootstrap", limit=5) connJobs = [j for j in jobs if (j.get("payload") or {}).get("connectionId") == connectionId] diff --git a/modules/serviceCenter/services/serviceExtraction/mainServiceExtraction.py b/modules/serviceCenter/services/serviceExtraction/mainServiceExtraction.py index 13f4a1d3..1ffb8557 100644 --- a/modules/serviceCenter/services/serviceExtraction/mainServiceExtraction.py +++ b/modules/serviceCenter/services/serviceExtraction/mainServiceExtraction.py @@ -33,6 +33,7 @@ class ExtractionService: self._interfaceDbComponent = getComponentInterface( context.user, mandateId=context.mandate_id, + featureInstanceId=context.feature_instance_id, ) self._extractorRegistry = getExtractorRegistry() if ExtractionService._sharedChunkerRegistry is None: