perf: batch tag reference counting
This commit is contained in:
@@ -52,6 +52,14 @@ type KnowledgeTagRepository interface {
|
||||
kbID string,
|
||||
tagID string,
|
||||
) (knowledgeCount int64, chunkCount int64, err error)
|
||||
// BatchCountReferences returns number of knowledges and chunks for multiple tags in a single query.
|
||||
// Returns a map of tagID -> {knowledgeCount, chunkCount}
|
||||
BatchCountReferences(
|
||||
ctx context.Context,
|
||||
tenantID uint64,
|
||||
kbID string,
|
||||
tagIDs []string,
|
||||
) (map[string]types.TagReferenceCounts, error)
|
||||
// DeleteUnusedTags deletes tags that are not referenced by any knowledge or chunk.
|
||||
DeleteUnusedTags(ctx context.Context, tenantID uint64, kbID string) (int64, error)
|
||||
}
|
||||
|
||||
@@ -32,3 +32,9 @@ type KnowledgeTagWithStats struct {
|
||||
KnowledgeCount int64 `json:"knowledge_count"`
|
||||
ChunkCount int64 `json:"chunk_count"`
|
||||
}
|
||||
|
||||
// TagReferenceCounts holds the reference counts for a tag.
|
||||
type TagReferenceCounts struct {
|
||||
KnowledgeCount int64
|
||||
ChunkCount int64
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user