Added GetFullLineCount() to the Rolodex

This commit is contained in:
Calvin Lobo
2024-08-15 10:35:31 -04:00
committed by quobix
parent 49a292152b
commit 43144dec72
2 changed files with 23 additions and 0 deletions

View File

@@ -626,3 +626,23 @@ func (r *Rolodex) RolodexFileSize() int64 {
}
return size
}
// GetFullLineCount returns the total number of lines from all files in the Rolodex
func (r *Rolodex) GetFullLineCount() int64 {
var lineCount int64
for _, v := range r.localFS {
if lfs, ok := v.(RolodexFS); ok {
for _, f := range lfs.GetFiles() {
lineCount += int64(strings.Count(f.GetContent(), "\n")) + 1
}
}
}
for _, v := range r.remoteFS {
if lfs, ok := v.(RolodexFS); ok {
for _, f := range lfs.GetFiles() {
lineCount += int64(strings.Count(f.GetContent(), "\n")) + 1
}
}
}
return lineCount
}

View File

@@ -1529,6 +1529,9 @@ func TestRolodex_SimpleTest_OneDoc(t *testing.T) {
assert.Nil(t, rolo.GetRootIndex())
assert.Len(t, rolo.GetIndexes(), 10)
lineCount := rolo.GetFullLineCount()
assert.Equal(t, int64(158), lineCount, "total line count in the rolodex is wrong")
assert.NoError(t, err)
assert.Len(t, rolo.indexes, 10)